Skip to main content

Command Palette

Search for a command to run...

Essential Linux Concepts for DevOps - Part 10- Service Management (systemd)

Updated
2 min read

systemd is a System Management Daemon that replaces the sysvinit process to become the first process with PID = 1, which gets executed in user space during the Linux start-up process. It is a system that is designed specifically for the Linux kernel. It is now being used as a replacement for init.d to overcome its shortcomings. It uses systemctl command to perform related operations.

e.g. $ systemctl start [service-name], $ systemctl poweroff

Once the system is successfully booted, the sysvinit process continues to run and waits for special commands like ‘shutdown’, which are used to shut down a Linux system. That means now the task of the sysvinit process is to shut down the system gracefully. For many years, the sysvinit remained a perfect system to bring up and shut down Linux-based systems. But as time passed by, the system became slow and inflexible, especially for modern-day computers.

So, in 2010 systemd was proposed to replace the widely used sysvinit system. Both systems have their own advantages but at last, it was decided to use systemd in place of sysvinit system

It comes pre-installed in various Linux based os such as Arch, Debian, Fedora, and Ubuntu.

Yet you can install it manually also.

Check the Current systemd Version using the below command.

Managing services with systemd:

Below is the list of some useful systemd utilities along with a brief description of what they do:

  • systemctl: It Controls the systemd system and services.

  • journalctl: Used To manage journal, systemd’s own logging system

  • hostnamectl: Can Control hostname.

  • localectl: Helps Configure system local and keyboard layout.

  • timedatectl: Used to Set time and date.

  • systemd-cgls : It Shows cgroup contents.

  • systemadm: It is a Front-end for systemctl command.

For example :

If you have to see all available services, running or not, you can execute the following command:

To stop and start services use the below commands:

systemctl stop [service-name]
systemctl start [service-name]

You can view the status of the service too, use the below command.

To restart a service:

$ systemctl restart [service-name]

Result 0 means the service is currently running and 1 means it is not.

To reboot the system, use one of the below commands.

systemctl halt
systemctl poweroff
systemctl reboot

More from this blog

Ashok Mahanthi's blog

30 posts