systemd upstart sysvinit start stop service

So you have lots of Linux servers and want a quick way to know if the one you are on at the moment is running systemd or upstart or sysvinit.  How should you start / stop / that service? It can be confusing with all the distro variations out there but perhaps some of these will help:

Perhaps this will help:

/usr/lib/systemd tells you you're on a systemd based system.
/usr/share/upstart is a pretty good indicator that you're on an Upstart-based system.
/etc/init.d tells you the box has SysV init in its history


The init process is always assigned PID 1. The /proc filesystem provides a way to obtain the path to an executable given a PID.

In other words:

nathan@nathan-desktop:~$ sudo stat /proc/1/exe
  File: '/proc/1/exe' -> '/sbin/upstart'
As you can see, the init process on my Ubuntu 14.10 box is Upstart. Ubuntu 15.04 uses systemd, so running that command instead yields:

nathan@nathan-gnome:~$ sudo stat /proc/1/exe
  File: '/proc/1/exe' -> '/lib/systemd/systemd'
If the system you're on gives /sbin/init as a result, then you'll want to try statting that file:

nathan@nathan-gnome:~$ sudo stat /proc/1/exe
  File: '/proc/1/exe' -> '/sbin/init'
nathan@nathan-gnome:~$ stat /sbin/init
  File: ‘/sbin/init’ -> ‘/lib/systemd/systemd’
You can also execute it to find out more:

[user@centos ~]$ /sbin/init --version
init (upstart 0.6.5)



So this is the newer in Ubuntu:

Starting with Ubuntu 15.04, Upstart will be deprecated in favor of Systemd. With Systemd to manage the services we can do the following:

systemctl start SERVICE - Use it to start a service. Does not persist after reboot

systemctl stop SERVICE - Use it to stop a service. Does not persist after reboot

systemctl restart SERVICE - Use it to restart a service

systemctl reload SERVICE - If the service supports it, it will reload the config files related to it without interrupting any process that is using the service.

systemctl status SERVICE - Shows the status of a service. Tells whether a service is currently running.

systemctl enable SERVICE - Turns the service on, on the next reboot or on the next start event. It persists after reboot.

systemctl disable SERVICE - Turns the service off on the next reboot or on the next stop event. It persists after reboot.

systemctl is-enabled SERVICE - Check if a service is currently configured to start or not on the next reboot.

systemctl is-active SERVICE - Check if a service is currently active.

systemctl show SERVICE - Show all the information about the service.

sudo systemctl mask SERVICE - Completely disable a service by linking it to /dev/null; you cannot start the service manually or enable the service.

sudo systemctl unmask SERVICE - Removes the link to /dev/null and restores the ability to enable and or manually start the service.

No comments: