What is the canonical method for removing a unit/service file from systemd?

afarley asked:

What is the systemd-approved method for removing e.g. sidekiq.service from /etc/systemd/system/?

Note, there are many related discussions on this topic such as this one which I have already read:
https://superuser.com/questions/513159/how-to-remove-systemd-services

My point of confusion is that the most-accepted answer in the above discussion requires the user to manually rm files from a bunch of locations, but a later answer suggests that systemctl disable <service> should have the same effect as manually removing the files.

According to my own testing of systemctl disable sidekiq, I am finding that the unit file sidekiq.service remains at /etc/systemd/system afterwards.

I understand that, in theory, using rm on a bunch of locations should do the trick, but I’m wondering how someone who is actually familiar with systemd or systemctl would do this. Is such brute force really necessary, or is there an actual systemctl command for this purpose?

My answer:


If you’re trying to uninstall software, then removing the file is the correct approach. But remember that systemd will remember the service until told to reload its configuration with systemctl daemon-reload. Then it will notice the unit is gone, and (if the service isn’t still running) forget about it.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.