The Serpent

// Cursing the Internet since 1998

systemd – The Linux System and Service Manager

Posted Aug 6, 2019 Updated Dec 21, 2020 Cheatsheet

systemd is a daemon manager, replacing the traditional run levels and shell scripts. It also includes several other components designed to replace other common Linux services, including inetd (Internet Services Daemon) and cron. It’s now the default on all major distro’s, replacing sysvinit.

This cheatsheet aims to provide basic usage instructions for common systemd tasks.

First, you can determine which init system you’re using by checking the process assoicated with PID 1, as follows:

	user@debian:~$ ps -p 1
	   PID TTY          TIME CMD
	     1 ?        00:00:02 systemd

systemd consists of other components:

Component Description
journald Event logger designed to replace syslog\rsyslog. Easily corrupts logs apparently
logind A login manager
networkd Network manager for interfaces. Very new with minimal support
timedated Time\Data manager for time zones, local time etc
systemd-boot Boot manager for Linux

systemctl is an admin tool to manage systemd, common commands include:

List all configured units (a unit can be many things, a service, a socket, a mount etc)

Systemctl status <service>
List information about service

Systemctl enable\disable <service>
Enable\Disable a service from startup

systemd uses concept of Unit Files - Configuration file describing something to monitor, can be of many types but mainly service & target. Systemd still works with System V init scripts, which Debian still uses for compatibility reasons, and can use existing /etc/init.d/.

Integration with System V

Debian still maintains System V init (sysvinit) scripts within /etc/init.d, and systemd can read these and use them as services, though modern services with full systemd support should start using unit files within /etc/systemd/.

Debian 9 removed the file /etc/rc.local with the idea being that service files take over. But this is overkill so you can use the command systemctl edit –full rc-local to create a service that basically executes whatever is in rc.local. Make sure you create the file and mark it as executable.

Service files

Unit files on Debian based systems live in /etc/systemd/system.

systemd – The Linux System and Service Manager
Posted August 6, 2019
Updated Dec 21, 2020
Written by John Payne