Pcornel
Linux · systemd & Services

systemd

Cheat sheet · https://pcornel.dk/topic.php?topic=363

Back to the Topic

Answer

systemd is the first process on a Linux system (PID 1) and the manager of everything after it: it reads unit files, works out start order, launches services and supervises each in its own control group.

Remember

A unit in /etc/systemd/system or a drop-in overrides the packaged one. With the default Type=simple, "started" only means the process was launched. After= orders; Wants=/Requires= pulls a unit in. A service that fails repeatedly hits a start limit.

First checks

  • systemctl cat <unit> — the effective unit with all drop-ins.
  • systemctl show <unit> -p Type,Restart,ExecMainStatus,NRestarts — key properties.
  • systemctl list-dependencies <unit> — what it pulls in.
  • systemd-analyze verify <unit file> — syntax and reference errors.
  • systemd-analyze critical-chain <unit> — what it waited for at boot.

Commands

systemctl status <unit>
Show systemd unit state and recent logs.
systemctl status
systemctl show
systemctl cat
systemctl list-dependencies
systemctl daemon-reexec
systemctl cat <unit>
systemctl reset-failed
systemctl daemon-reload

Verify in this order

unit files read (etc over run over usr/lib, plus drop-ins) → daemon-reload → dependency and order graph → start job → readiness according to Type= → supervised in a control group → restarted per Restart=

Where it usually breaks

First mismatch in persistent unit/config/generator → dependency/order graph → systemd state → process/cgroup → socket/resource dependency → journal → consumer check; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=363

Confirmation

Confirm action

Continue?