How to disable a service in Linux

In the past it was easy, just remove the file from init.d directory … but that was then when all the Linux distros where SysV.

These days most of the systems are using systemd and is still easy. (I will post separately about sysv, upstart and systemd).

BTW, by “disable” I mean stop a service starting at boot time.

But how do you know your distro is systemd ? Easy run this in your console :

# stat /proc/1/exe
  File: /proc/1/exe -> /lib/systemd/systemd

So how do you do it in systemd ?

  • Typing simply : systemctl will print information for all services

to see the status of a specific service do this :

sudo systemctl status service-name

to start and stop a service :

sudo systemctl start service-name
sudo systemctl stop service-name

and finally to disable it :

sudo systemctl disable service-name