Control services on Linux (systemV, systemd, initctl…)

On Linux, there’s many ways to control services that can run on your system. Here are the main and most known init systems that you can find on the common distros, depending on their version.

SystemV

That system is one of the oldest and one of the most common. Its init scripts are stored in /etc/init.d/

To list all the available services, you have to use that command:

service --status-all

To perform an action on one of those services, you will be using:

service PROCESS_NAME (start|stop|restart|status)

Upstart (initctl)

Upstart is a successor of SystemV scripts. It works asynchronously, and its scripts are stored in /etc/init/

To list all the available scripts, you have to use that command:

initctl list

To perform an action on one of those services, you will be using:

initctl (start|stop|restart|status) PROCESS_NAME

SystemD

Its name SystemD means System Daemon. It manages daemons that can be running on a system. It’s a successor of upstart and allows a more flexible management for the services. Init scripts are stored in /etc/systemd/system/

To list all the available scripts, you have to use that command:

systemctl --list-units
systemctl --list-unit-files

To perform an action on one of those services, you will be using:

systemctl PROCESS_NAME (start|stop|restart|status)

SupervisorD

Finally, SupervisorD is a supervisor focusing mainly on the applications more than the system. It allows management of applications execution and control their life like you could do with system services.

To display all the applications managed by supervisord:

supervisorctl status all

To control those processes, you will be using:

supervisorctl (start|stop|restart|status) PROCESS_NAME