What is SystemD on Linux?

Linux TLDR
Last Updated:
Reading time: 3 minutes

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.

Why SystemD?

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?

Lennart Poettering and Kay Sievers, both working at Red Hat, developed the Systemd after being inspired by macOS’s launchd and Upstart to create a modern and dynamic system.

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.

😮
When SystemD came out in 2010, it was the only software suite that had aggressive parallelization capabilities during system boot as well as central management for processes, daemons, services, and mount points.

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.

Unit TypeFile ExtensionDescription
Service unit.serviceSystem Service.
Target unit.targetGroup of systemd units.
Automount unit.automountFile system automount point.
Device unit.deviceDevice file recognized by the kernel.
Mount unit.mountFile system mount point.
Path unit.pathFile or directory in a file system.
Scope unit.scopeExternally created process.
Slice unit.sliceGroup of hierarchically organized units that manage system processes.
Snapshot unit.snapshotSaved state of the systemd manager.
Socket unit.socketInter-process communication socket.
Swap unit.swapSwap device or a swap file.
Timer unit.timerSystemd timer.

The following is a list of known directories used by popular distributions to store unit files.

Directory PathDescription
/usr/lib/systemd/user/By default, whenever software installs unit files, it places them in this location.
/etc/systemd/system/If you wish to modify the default unit files, this can be the best location.
/run/systemd/system/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

Output:

Mounted units file

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

Output:

Checking the status of specific unit file

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

Output:

Content of the unit configuration file

Conclusion

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!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.