« Back to Systemd: Frequently Asked Questions

How to use systemctl edit to change a service?

Systemd allows service units to be configured using a drop-in file, which is often called override.conf. It overrides the vendor-supplied version of a service to customize it. Instead of duplicating the configuration, the override file contains the differences.

Editing service file

Changing a service can be done using systemctl, followed by the edit subcommand and service unit. The editor that is configured on the system will be opened and any changes can be made between the comment section at the top and the comment section a little bit lower. Do not remove these comment sections, as systemctl uses these to see what changes you made.

Editing the primary unit

To edit the main configuration file, use the --full option. This is typically not a good idea for services that were installed using a package manager, but it is for your custom service units.

systemctl edit --full myservice.service

Overriding list entries

Some properties of a service may be repeated. These lists may for example define a path. It might be needed to first reset that property by defining it in your override file with an empty value. After that entry, add them in. If you also need the values from the original main configuration, add those as well.

Configuration check

After the edit action, ensure that the configuration has the right entries.

systemctl cat myservice.service

Activating changes

When making changes to units, a reload of systemd might be needed.

systemctl daemon-reload

Then reload the service.

systemctl restart myservice.service

Learn more about systemctl

This article uses the systemctl command to achieve its tasks. For this popular tool there is a cheat sheet available!

» Mastering the tool: systemctl

systemctl cheat sheet

Other questions related to systemd

Feedback

Is the described answer not working or incorrect, got another tip or question? Share your thoughts!