Open In App

Linux – Systemd and its Components

Last Updated : 16 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Systemd is a system that is designed specifically for the Linux kernel. It replaces the sysvinit process to become the first process with PID = 1, which gets executed in user space during the Linux start-up process.  

Why systemd?

It is one of the first questions that came up to mind when discussing systemd. To find the answer, we have to first know a bit about the sysvinit. If we forget about systemd and the other similar systems, then it’s safe to say that sysvinit is the first process started by the kernel when you boot up any Linux or Unix computer. This means that all the other processes are their child in one way or the other.

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 gracefully shutdown the system. For many years, the sysvinit remained a perfect system to bring up and shutdown 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.

How to install systemd

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

Yet you can install it manually also.

Check Current systemd Version:

systemctl --version

What is Linux Systemd and Its Components

Get tar update:

https://www.freedesktop.org/software/systemd/systemd-216.tar.xz

What is Linux Systemd and Its Components

Extract file:

We use -J switch to extract the package:

tar -xJf systemd-216.tar.xz

What is Linux Systemd and Its Components

Installation preparation:

Have to install following packages for better installation

apt-get install gcc intltool gperf glib2-devel

Now type these commands :

cd systemd-216
pwd

What is Linux Systemd and Its Components

Configure:

Let us now configure the package

./configure

What is Linux Systemd and Its Components

Install: 

Let’s install

make install

What is Linux Systemd and Its Components

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:

systemctl list-units --type service --all

What is Linux Systemd and Its Components

To start a service:

systemctl start [service-name]

Linux Systemd and Its Components

To stop a service:

systemctl stop [service-name]

Linux Systemd and Its Components

To restart a service:

$ systemctl restart [service-name]

Linux Systemd and Its Components

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

To reboot the system, the command used is as under:

systemctl halt
systemctl poweroff
systemctl reboot

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads