How to use systemctl edit to change a service?
Introduction into changing systemd units
Systemd allows service units to be changed and customized. This is done 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 a service file
Changing a service can be done using systemctl, followed by the edit subcommand and the service unit.
systemctl edit myservice.service
When using this command, it will open your default editor, such as vi. At this stage you can make any changes to the service file. Any changes should be placed 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