Units and state
What systemd manages
Understand PID 1, the service manager, units, and why systemd owns more than background processes.
8 minute lesson
When the kernel finishes booting, it starts exactly one process. On most Ubuntu servers that process is systemd, running as PID 1. Every other process on the machine descends from it.
Check it yourself:
ps -p 1 -o pid,comm,args
PID COMMAND COMMAND
1 systemd /sbin/init
/sbin/init is a symlink to the systemd binary. The name survives from older init systems, but the process is systemd.
Units, not scripts
Older init systems treated startup as a pile of shell scripts that ran in order. systemd models the system as units: named objects with a type, a state, and relationships to other units.
Services are the unit type you will touch most, but they are not the only one. Sockets, timers, mounts, paths, targets, and devices are units too. A timer can activate a service. A target can group dozens of units into one named system state, like multi-user.target.
This is why systemd owns more than background processes. It knows that your backup timer triggers backup.service, that nginx.service wants the network first, and which control group every process belongs to.
See what it tracks
List the services running right now:
systemctl list-units --type=service --state=running
UNIT LOAD ACTIVE SUB DESCRIPTION
cron.service loaded active running Regular background program processing daemon
nginx.service loaded active running A high performance web server
ssh.service loaded active running OpenBSD Secure Shell server
Swap --type=service for --type=timer or --type=socket and you see the other unit types the manager is tracking. The manager holds their state and relationships instead of treating startup as one long shell script.
Connect the two views: the process tree hanging off PID 1, and the unit list describing why each piece of it exists.
One habit to build early: when a process misbehaves, ask systemd about it before reaching for ps. ps tells you a process exists. systemd tells you which unit owns it, why it started, and what happens when it dies.
Lesson completed