Linux SystemdSystemd is a system and service manager for Linux.

It initializes and manages/maintains/tracks system services.

Systemd is the first process started by the Linux kernel during boot-up, and as such has a process id (PID) of 1.

Systemd then starts the required daemons, processes and services that are required to make the system work.

Systemd targets determine which daemons, processes and services are started, and so targets are as good a place to begin as any other.

Systemd Targets (Previously Runlevels)

Unlike runlevels, systemd targets are not numbered, but rather named.

Each systemd target unit — ending with a .target file extension — links together the various system services that are dependent on one another, so that they might all be initiated or altered as the need arises.

The common systemd “runlevel” (initiation) targets are:

Target Unit Function
poweroff.target Shuts Down & Powers Off the System
rescue.target Sets Up a Rescue Shell
multi-user.target Sets Up a Non-Graphical Multi-User System
multi-user.target Sets Up a Non-Graphical Multi-User System
multi-user.target Sets Up a Non-Graphical Multi-User System
graphical.target Sets Up a Graphical Multi-User System
reboot.target Shuts Down & Reboots the System

Target units can be changed and configured with the systemctl command.

To view the current default target unit, use: systemctl get-default

To list the current target units, use: systemctl list-units --type target

To change the current target, use: systemctl isolate name.target

Systemd Service Management

Under the old SysVinit system, the service command was used to control the state of system services.

Under systemd, the systemctl command is used to control the state of system services, which are identified as service units by their .service file extensions.

The systemctl list-units --type service command will list the loaded system services, and confirm whether or not they are active or inactive.

The systemctl list-units --type service --all command will list all loaded system services, regardless of their state.

The systemctl list-unit-files --type service command will list all available system units, along with whether or not they are enabled.

To control the state of system services, use systemctl, followed by the unit command, and then the system service name. Some common examples are:

systemctl start name.service
systemctl stop name.service
systemctl restart name.service
systemctl try-restart name.service
systemctl reload name.service
systemctl status name.service
systemctl is-active name.service
systemctl enable name.service
systemctl disable name.service
systemctl status name.service
systemctl is-enabled name.service

Run man systemctl for the full list of options.

Power Management Services

Last but not least, several systemd commands are available to manage the “power” of your PC, such as halting, rebooting, shutting down, etc.

The old commands are still available, but it is recommended to switch over to the new as soon as possible, to cause less confusion if/when the old are no longer supported.

The systemd commands are:

systemctl halt
systemctl poweroff
systemctl reboot
systemctl suspend
systemctl hibernate
systemctl hybrid-sleep

Most, if not all, of the power commands must be run as the root user.

Conclusion

As always, there is more to systemd than can be covered in the scope of this introduction, but these basics should be enough to get you started.