This article will teach you what systemd is and why it replaced SysVinit; what systemd unit files are; how to list all and specific unit files; and how to view the content of a unit configuration file.
To understand Systemd, you must first understand SysVinit (or init) and why it was replaced by systemd. Earlier, the first process to start with the system was SysVinit, which swamped other processes in the system.
Once the system has successfully booted, the SysVinit process keeps running to take care of different parts of the running system until the user sends the halt signal, which is basically the same thing as shutting down the system.
For a while, SysVinit remained the default choice for most distros, but as modern Linux distributions came along, it became slow and inflexible. One of the reasons stated was that init starts the process in series, unlike the parallelism supported by systemd.
Still, both systems have their own advantages, but for now, let’s focus on what systemd has to offer, which became the reason for the SysVinit replacement.
What is SystemD?
But first, let me define systemd for you before I tell you more about it. So, it’s the first process with PID 1 that is started by your kernel once you boot your system. The rest of the (child) processes are swamped by systemd and run in the background until the system shuts down.
Until now, everything has been identical to SysvInit, so what makes it different? It’s the features like on-demand starting daemons, (auto)mount point maintenance, snapshot support, and process tracking using the Linux control groups.
The most notable feature of systemd was its parallelization capabilities and dependency-based service control logic, which allowed your system to start multiple processes in parallel, indirectly improving the boot time.
Apart from that, systemd provides the systemctl command-line tool to manage your system services (also referred to as “daemons” or “systemd units“) to help you with common system administrator tasks.
What are SystemD Units?
The systemd introduces the concept of units to manage different services in your system, like a service unit, mount unit, socket unit, slice unit, etc.
The units is referred to unit configuration files that includes the information about the unit types and its working which is used to operate and manage the services.
The following is a list of available systemd unit types.
|Group of systemd units.
|File system automount point.
|Device file recognized by the kernel.
|File system mount point.
|File or directory in a file system.
|Externally created process.
|Group of hierarchically organized units that manage system processes.
|Saved state of the systemd manager.
|Inter-process communication socket.
|Swap device or a swap file.
The following is a list of known directories used by popular distributions to store unit files.
|By default, whenever software installs unit files, it places them in this location.
|If you wish to modify the default unit files, this can be the best location.
|This directory is for run-time units that have high priority before the above two.
Listing All the Mounted Units
The following command will give you the list of all mounted units in your memory.
$ systemctl list-units --type=mount
Checking the Status of the Referenced Mount Unit
From the above list of mounted units, you can select one and check its status using the following command:
$ systemctl status boot-efi.mount
As you can see from the above list, the systemctl command gives you a lot of information about the unit, followed by:
- Unit Status
- Location of the mount
- Path or UUID to mount.
- Links to documentation
- Task, memory, and CPU
- Corresponding CGroup
This information is defined in all unit’s configuration files.
Inspect the Unit Configuration File
The following command will display the contents of a referenced unit file, which can be inspected.
$ systemctl cat boot-efi.mount
Systemd is the most popular service management utility right now that also provides backward compatibility support for “init” scripts.
Although, the focus of this article is not to give you a comprehensive guide, but to highlight this part, as there are already great articles available on the internet.
If you want me to extend this topic more, or have any questions or queries related to this topic, then feel free to ask them in the comment section.
Till then, peace!