systemd – Overriding an existing systemd unit

How does one override a systemd unit for a package that was installed by the system’s package manager? (E.g. APT or Yum.)

It’s simple!

Just install your own unit file in /etc/systemd/system. systemd will look there before it looks in /usr/lib/systemd/system.

For additional info, see the section System Unit Search Path in the systemd.unit documentation.

Why not just edit the unit in /usr/lib/systemd/system?

If you’d do that, your changes would conflict with the package’s unit the next time you upgrade or re-install the package.

Author: Carl Winbäck
Published: 2023-03-03

Back to the main page