Linux & Systems

systemctl cat and Drop-In Overrides

Inspect the complete systemd unit and make a small local override without editing vendor files.

1 min read
#systemd#systemctl#configuration#linux

A tranquil mountain lake at sunset

Photo: Unsplash.

Before changing a systemd service, inspect the unit fragments systemd is actually combining:

systemctl cat example.service
systemctl show -p FragmentPath -p DropInPaths example.service

Avoid editing files under /usr/lib/systemd/system or /lib/systemd/system. Package upgrades can replace them. Create a drop-in instead:

sudo systemctl edit example.service

For a small environment addition, the editor can contain:

[Service]
Environment=LOG_LEVEL=info

Save, then reload and restart deliberately:

sudo systemctl daemon-reload
sudo systemctl restart example.service
systemctl status example.service

Some settings are lists. Repeating them may append rather than replace. To replace ExecStart, first clear the existing value:

[Service]
ExecStart=
ExecStart=/usr/local/bin/example --config /etc/example/config.yaml

That empty assignment is significant. Confirm the merged result with systemctl cat and inspect runtime properties with systemctl show.

To remove local overrides created by systemctl edit, use:

sudo systemctl revert example.service

Review what it will affect first, especially if other administrators maintain drop-ins. For configuration that belongs to your infrastructure repository, manage an explicit file such as /etc/systemd/system/example.service.d/override.conf and deploy it predictably.

References