What is the best, most correct way to customize SystemD unit files that come from packages?
Packages will leave their files in
/usr/lib/systemd/system . I used to just copy those files into
/etc/systemd/system and edit them as needed. But is this the best way?
Yes! You can create override files! If you create a directory like
/etc/systemd/system/some-unit.service.d and create files named
*.conf in there they will also be ready by SystemD (after a
One trick is that to override some things like
ExecStart= you need to first declare an empty one to reset it if the
[Service] ExecStart= ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
You can also use
systemctl edit some-unit.service to create and edit the file in one go. This will create
override.conf for you, so that’s probably a best bet for naming any override files you might create.
I learned this from this excellent answer on AskUbuntu.