How to override systemd unit file settings?

systemctl edit will create a drop-in file where you can override most of the settings, but these files have some specifics worth mentioning:

Note that for drop-in files, if one wants to remove entries from a setting that is parsed as a list (and is not a dependency), such as AssertPathExists= (or e.g. ExecStart= in service units), one needs to first clear the list before re-adding all entries except the one that is to be removed.

#/etc/systemd/system/httpd.service.d/local.conf
[Unit]
AssertPathExists=
AssertPathExists=/srv/www

Dependencies (After=, etc.) cannot be reset to an empty list, so dependencies can only be added in drop-ins. If you want to remove dependencies, you have to override the entire unit.

To override the entire unit, use systemctl edit --full, this will make a copy in /etc if there is none yet and let you edit it.

See also Systemd delete overrides


You may override a systemd unit file using

systemctl edit mysqld.service

Any statements made in the override file will take priority.

Tags:

Systemd