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.
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 systems 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:
Get tar update:
We use -J switch to extract the package:
tar -xJf systemd-216.tar.xz
Have to install following packages for better installation
apt-get install gcc intltool gperf glib2-devel
Now type these commands :
cd systemd-216 pwd
Let us now configure the package
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
To start a service:
systemctl start [service-name]
To stop a service:
systemctl stop [service-name]
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, the command used is as under:
systemctl halt systemctl poweroff systemctl reboot