How to remove a systemd service

I’m not sure why systemd doesn’t remove the service, but to do so you can run through the following commands. Also check /etc/init.d/[servicename] as there may be a wrapper there as well.

If you know what service you’re looking to remove, great. If not, you can quickly find all the systemd services enabled on your system with the following command:

systemctl list-unit-files | grep enabled

You can inspect the service and find any unit information for it using the following:

systemctl cat [servicename]

To continue on, stop, disable and remove the unit links as shown below.

systemctl stop [servicename]
systemctl disable [servicename]
rm /etc/systemd/system/[servicename]
rm /etc/systemd/system/[servicename] # and symlinks that might be related
rm /usr/lib/systemd/system/[servicename]
rm /usr/lib/systemd/system/[servicename] # and symlinks that might be related
systemctl daemon-reload
systemctl reset-failed

Published by

Rich

Just another IT guy.

Leave a Reply

Your email address will not be published. Required fields are marked *