How Systemd Is Different From SysVinit?


Gaming Laptop Series

What Is init

In Unix or Unix based systems init is the first process that gets started during system boot. It is the parent process of all the processes that are running into the system. It automatically adopts all the processes that get orphaned. init holds the process id 1. Once it gets started it continues running until the system is shutdown.


What is SystemV (SysV)

Unix System V(five) is often abbreviated as SysV. It was one of the first commercial Unix operating system developed by AT&T that was released in 1983. A new style of system startup configuration was used in Unix system v and therefore it was called SysVinit. Later it was used in various other Linux distributions.

Sysvinit is a traditional init system for Unix/Linux whose primary purpose is initializing, managing, and tracking system services and daemons. Over the years several alternatives of traditional init system have been released to counter the design limitations.

Runlevels

A runlevel is the state of init process that can be used by the system to determine in which mode it has to operate. Each runlevel has a certain number of services stopped or started, these levels are identified by numbers. Generally, there are seven runlevels exist numbered from 0 to 6.

Once Linux kernel gets booted, the init program reads the /etc/inittab file to determine the behavior for each runlevel. Many Linux distribution boot by default in runlevel 3 or 5. These are the standard runlevel that are discussed in this article, a new runlevel can be created or existing ones can be modified by a user according to the requirement.

Mostly used SysV service commands are

sudo service start service-name – the command will start the given service

for example-

sudo service start apache2 This command will start the apache server in the system using systemVinit.

sudo service stop service-name -this command is used to stop a service
sudo chkconfig service-name on -enable the service at boot,  for example – apache2 will start its services once the system boot completed.

sudo chkconfig – display a list of enabled or disabled services on boot with runlevels information
sudo chkconfig service-name off– disable the service at boot
sudo service service-name restart– this command will restart a given service
sudo service service-name status – Will display the status of an individual service
chkconfig example –list –  check if a service is configured to start on boot or not


What is Systemd in the modern Linux system

systemd is a newer init system. It includes various features like on-demand starting daemons, snapshot support, process tracking, and inhibitor locks, etc. It replaces Unix traditional system v and BSD init system and nowadays systemd is adopted by a majority of Linux distributions. The systemd is compatible with SysV and LSB init scripts.

What is systemctl?

systemctl is a utility that is responsible for controlling a widely adopted init system and service manager systemd.

Some commonly used systemctl service commands are

sudo systemctl start service-name -To start a service
sudo systemctl stop service-name -Use to stop a systemd service
sudo systemctl enable service-name -enable the service at boot,apache2 will start its services once the system boot completed.
sudo systemctl disable service-name– disable the service at boot
sudo systemctl restart service-name– this command will restart the apache2 services
sudo systemctl status service-name– Will display the status of individual service
systemctl is-enabled service-name – check if a service is configured to start on boot or not

Some other commands used in systemd are-

hostnamectl – Use to control the hostname, there are various options that are available to use with this command
for example-
hostnamectl set-hostname --pretty new_hostname
teamdctl – The team daemon control tool, allows a user to interact with a running teamd instance.
timedatectl – Control the system time and date, It may be used to query and change the system clock and its settings
journalctl– Query the systemd journal
systemd-analyze or systemd-analyze time–  Check the system boot time
systemd-analyze blame– Check each service time consumption at startup
systemctl kill service-name– Kill all the processes associated with the given service
systemctl – List all running services
systemctl status – Shows system status

What are the Systemd targets?

systemd targets are a similar concept to runlevels and also serves a similar purpose. But operates slightly differently. Each target named instead of numbers that are intended to serve a specific purpose. systemd targets are represented by target units which end with .target file extension.

To explore more about systemd targets or if you are intended to working with system targets then you should visit Working with systemd targets. If you have to say something on the topic, please write to us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.