Systemd is a suite of utilities that provide an array of system components for the Linux OS. We look at various components within systemd.
Table of contents.
- Systemd components
Systemd is responsible for initializing and managing services in Linux. With systemd, we are also able to start different processes simultaneously which results in faster booting.
In this section, we discuss various systemd components, they include;
This is a UEFI boot manager responsible for executing configured EFI images in both windows and Linux.
It operates on the EFI System Partition(ESP) which stores configuration file fragments, initrds, and other EFI images.
We use bootctl to check EFI firmware status, list and manage boot loaders, install, update and remove boot loaders, etc.
For example to update systemd-boot we write:
$ bootctl update
This service is used to manage user logins on devices, other functions include;
- Tracking users, their sessions and processes, statuses, idle states.
For example to view current sessions we write:
$ loginctl list-sessions
To kill a session we write:
$ sudo loginctl kill-session 2
- Implementing the shutdown/sleep inhibition logic for system applications.
- Controlling groups for user processes.
- Multi-seat management.
- Manage access to devices for users.
- Spawning text logins automatically.
For more information we can open the command manual:
$ man systemd-logind # OR $ man loginctl
This system daemon allows users to manage network configurations such as virtual networks, bridges, VLANs, tunnels, VXLAN, bonding, and more.
It can also detect network devices as they appear on the network.
To list all network configuration files we write:
$ ls /usr/lib/systemd/network/
Other config files are located in /run/systemd/network/ and /etc/systemd/network/
Among these the one located in the /etc/systemd/network directory has the highest priority:
$ ls /etc/systemd/network
This is the logging system of systemd. When systemd is running this service is used to collect and store logging data. It creates a well-structured index journal based on this logging data from various sources.
Journal files are located in the /var/log/journal/ directory:
$ ls /var/log/journal/
The journalctl command is used to query the systemd journal.
To display messages from the system boot we write:
$ journalctl -b
We can also use it to read user journals.
Let's list journals:
$ ls /var/log/journal/e67b22f30ed44931b2a8aa5804f2554e/
To read a journal, we write:
$ sudo journalctl --file /var/log/journal/system.journal
For other command options we write:
$ man journalctl # OR $ journalctl --help
These are timers that can be used in the place of crontab daemon.
Timers can be real-time timers which activate in a calendar event or monotonic which activates after a specified period that is relative to a starting point.
Calendar time events and monotonic time events come built-in into this service hence allowing scheduling down to the minute granularity.
By using this service we are assured a scheduled event will be executed even if the time it was supposed to be executed the machine was powered off.
It is also possible to run events asynchronously.
Timers are stored in the /var/lib/systemd/timers/ directory;
$ ls /var/lib/systemd/timers/
For example, we can list timers as follows:
$ systemctl list-timers
They can be viewed as a combination of cron and anacron with added pros, e.g;
- Jobs are logged in the journal for easier debugging.
- A job can be configured to tun in a specific environment.
- Jobs can rely on other systemd units. etc.
Others but not all components include:
This is used for the setting of basic system settings before or during the first boot of a newly created system, with it we can change settings such as the timezone, hostname, root password, etc.
This command should not be executed on an already running system since it interacts with the file system directly.
It provides portable human user accounts that are not dependent on the system configuration.
This portability is a result of moving all user-related data into an encrypted storage medium.
This user data includes user-name, host-name, groups, GID, UID etc.
It also upholds security by managing a home directory encryption and log in so that when not in use it can be locked.
For example to create a new user we write:
$ homectl create newUser
It is used to run a command or a whole operating system in a lightweight namespace container.
This is viewed as chroot on steroids since it virtualizes the file system hierarchy, process tree, IPC subsystems, hostnames, and domain names.
This is a system service that provides network name resolution to local applications by using a caching and validation DNS/DNSSEC stub resolver together with an LLMNR and MulticastDNS resolver and responder.
It is used to create system users and groups based on the file format and specified location.
It synchronizes the system clock across the network by using an SNTP client which queries a remote server and synchronizes its local clock.
The local time is saved to the disk every time the clock synchronizes and on subsequent reboots, the stored local time is used.
Generally, systemd manages units, units can be of different types, for example, sockets, services. These units are configured and their configurations are stored in unit files.