systemd#

The service manager on most modern Linux distributions. Systemd is the very first process that starts after the kernel is loaded, and it takes care of starting all other processes and services on a Linux system.

unit#

An item that is managed by Systemd. Different types of units exist:

[root@rocky9 ~]# systemctl -t help
Available unit types:
service
mount
swap
socket
target
device
automount
timer
path
slice
scope

Overview of units & targets#

systemctl overview commands:

Command Description
systemctl -t service Shows only service units
systemctl -t target Show current loaded active targets
systemctl get-default Show default boot target
systemctl set-default <target> Set default boot target
systemctl list-units -t service Shows all active service units (same as previous command)
systemctl list-units -t service --all Shows all inactive & active service units
systemctl --failed -t service Shows all failed service units
systemctl status -l <name>.service Shows detailed status information about a service

Unit dependencies#

Find out which dependencies a unit has:

systemctl list-dependencies <unitname>

Find out which units are required for this unit to be started:

systemctl list-dependencies <unitname> --reverse
systemctl cat <unitname>

Unit options#

Show available unit options:

systemctl show
# or
systemctl show <unitname>

Editing units#

systemctl edit <unitname>

Reload systemd units#

Reload systemd unit files after editing or making changes:

systemctl daemon-reload

target#

In Systemd, a collection of unit files that can be managed together.

Set default boot target#

Check current default boot target:

[root@rhel9-a ~]# systemctl get-default
multi-user.target

Set default boot target:

systemctl set-default multi-user

halt, poweroff, reboot, and shutdown#

halt, poweroff, reboot, and shutdown are systemd targets in later versions of RHEL. They're symbolic links to systemctl.

[root@rhel9-a ~]# ll /usr/sbin/{halt,poweroff,reboot,shutdown}
lrwxrwxrwx. 1 root root 16 Apr  8 11:53 /usr/sbin/halt -> ../bin/systemctl
lrwxrwxrwx. 1 root root 16 Apr  8 11:53 /usr/sbin/poweroff -> ../bin/systemctl
lrwxrwxrwx. 1 root root 16 Apr  8 11:53 /usr/sbin/reboot -> ../bin/systemctl
lrwxrwxrwx. 1 root root 16 Apr  8 11:53 /usr/sbin/shutdown -> ../bin/systemctl

want#

An indication for a Systemd unit file that is supposed to be started from a specific Systemd target.

...
[Install]
WantedBy=multi-user.target

If a service is enabled it's a symlink in a directory of the target name so that Systemd knows to start the service as part of that group of units.

[root@rocky9 ~]# systemctl enable vsftpd
Created symlink /etc/systemd/system/multi-user.target.wants/vsftpd.service → /usr/lib/systemd/system/vsftpd.service.

In Systemd terminology, this symbolic link is known as a want, as it defines what the target wants to start when it is processed.