systemd – The Linux System and Service Manager
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 PID1, as follows:
user@debian:~$ ps -p 1
PID TTY TIME CMD
1 ? 00:00:02 systemd
user@debian:~$
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:
Systemctl
List all configured services
Systemctl status <service>
List information about service, or without provides general overview of services
Systemctl enable\disable <service>
Enable\Disable a service from startup
systemd uses concept of Unit Files - Configuration file describing a service, 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.