brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: systemctl revert throws away every override of a unit

Linux
~/tips/tip-systemctl-revert-unit-overrides

sudo systemctl revert example.service

Removes drop-ins and overrides of a unit so it goes back to the vendor version.

After a few rounds of systemctl edit a unit can collect drop-ins nobody remembers. There is a one-command way back to what the package shipped.

This one deletes files, so look at what you have first:

systemctl cat example.service
sudo systemctl revert example.service

The man page says revert puts a unit back to its vendor version. It removes the drop-in directory (example.service.d/, with everything in it) below /etc/systemd/system and /run/systemd/system. If a vendor-supplied unit file exists below /usr/, a unit file that overrides it is removed too. A masked unit gets unmasked.

Effectively it undoes what systemctl edit, systemctl set-property and systemctl mask did. The command is listed as added in version 230.

One detail to remember: when a unit has no vendor version, because it only exists below /etc/systemd/system, the unit file itself is not removed. So a service you wrote yourself survives, but its drop-ins do not.

Afterwards run systemctl cat example.service again to confirm only the original is left. A running service keeps running with the settings it started with, so restart it when you want the vendor settings to apply.

There is no undo. If a drop-in holds a setting you still need, copy the file somewhere safe before you revert.

Further reading: systemd: systemctl man page

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link