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 edit with drop-in names keeps several systemd overrides apart

Systemd
~/tips/tip-systemd-edit-drop-in

sudo systemctl edit --drop-in=limits myapp.service

Give each override of a unit its own named file instead of one big override.conf.

systemctl edit always writes to override.conf. Over time that one file collects resource limits, environment lines and hardening experiments all mixed up.

The --drop-in= option picks the file name instead:

sudo systemctl edit --drop-in=limits myapp.service
sudo systemctl edit --drop-in=hardening myapp.service

Each one opens your editor on its own file, limits.conf and hardening.conf in /etc/systemd/system/myapp.service.d/. After saving, systemctl prints a line like Successfully installed edited file '/etc/systemd/system/demo.service.d/nice.conf', reloads the unit, and the new setting is live.

I like small named files, because they make the history readable. You see what each file is for, you can delete one experiment without touching the rest, and config management can own one file while you test with another. systemctl cat myapp.service still shows everything merged in order.

The files are applied in alphabetical order, and for settings that take one value the last file wins. If two drop-ins set the same thing, name them with number prefixes, such as 50-limits and 90-local, so you know which one wins. The option is not in very old systemd; Ubuntu 24.04 has it.

Further reading: systemctl man page, systemd.unit man page

More Systemd tips [Service] sudo mkdir -p /etc/systemd/system/service.d [Service] printf 'hunter2' | sudo systemd-creds encrypt --name=dbpass – dbpass.cred systemd-analyze timespan 1h30min All Systemd tips (88) All topics

Link