Skip to content

Systemd

The systemd daemon manages start-up for Linux, including service start-up and service management in general. It activates system resources, server daemons, and other processes both at boot time and on a running system.

In RHEL, the first process that starts (PID 1) is systemd.

systemd uses units to manage different types of objects. Service units have a .service extension, socket units have a .socket extension and path units have a .path extension.

Use the systemctl command to manage units.

systemctl list-units --type=service --all

Use status to view the status of a specific unit:

systemctl status sshd

Use start, stop and restart to control services:

systemctl start sshd
systemctl restart sshd
systemctl stop sshd

Masking a service prevents an administrator from accidentally starting a service that conflicts with others.

systemctl mask sendmail.service

Enable services to ensure services automatically start when a system reboots.

systemctl enable sshd

To see the enabled or disabled states of all service units:

systemctl list-unit-files --type=service

systemctl poweroff stops all running services, unmounts all file systems and then powers down the system. systemctl reboot stops all running services, unmounts all file systems, and then reboots the system.

You can also use the shorter version of these commands, poweroff and reboot, which are symbolic links to their systemctl equivalents.

A systemd target is a set of systemd units that the system should start to reach the desired state.

Commonly used targets include graphical.target and multi-user.target for text-based logins.

Change to a target runtime:

systemctl isolate multi-user.target

Set the defualt:

systemctl get-default
systemctl set-default multi-user.target

Summary

Use the systemctl status command to determine the status of system daemons and network services started by systemd. The systemctl list-dependencies command lists all service units upon which a specific service unit depends. reboot and poweroff reboot and power down a system, respectively. systemctl isolate OPTION.target switches to a new target at runtime. Use systemctl get-default and systemctl set-default to query and set the default target.

Command References:

systemd, systemd.unit, systemd.service, systemd.socket and systemctl.