Remove Systemd Service on Ubuntu

Shegun Babs
Shegun Babs Mon Sep 2021

If you install a new init system service and then decide you do not want the application the init service process manages anymore and delete it, the service is still listed when you check the service list using systemctl and shows up as error or failed

Below is my recipe for removing such service

List the services first

$ systemctl list-units

Filter service name to be double sure

$ systemctl list-units | grep [service-name]

Remove service from list

$ systemctl stop [service-name]
$ systemctl disable [service-name]
$ sudo rm /etc/systemd/system/[service-name]
$ sudo rm /usr/lib/systemd/system/[service-name]
$ systemctl daemon-reload
$ systemctl reset-failed