Run and troubleshoot Linux services with systemd
8 steps · about 3 h 45 min · Intermediate
- Get the systemd mental model (guide, ArchWiki, 30 min)
See units, targets and dependencies as one picture before running individual commands.
- Control services with systemctl (reference, freedesktop.org, 25 min)
Practise start, stop, enable, status and is-failed on a real service and learn what each state means.
- Read the shape of a unit file (reference, freedesktop.org, 30 min)
Learn the [Unit] and [Install] sections, ordering versus requirement, and where override files go.
- Write your own service unit (reference, freedesktop.org, 35 min)
Choose the right Type=, ExecStart= and Restart= values to keep a small program running after crashes.
- Filter logs with journalctl (reference, freedesktop.org, 25 min)
Narrow logs by unit, boot, priority and time so a failing service explains itself.
- Keep the journal persistent and bounded (guide, ArchWiki, 20 min)
Make logs survive reboots and cap their disk use so troubleshooting data is there when you need it.
- Schedule jobs with timers (guide, ArchWiki, 25 min)
Replace a cron entry with a timer and service pair whose runs and failures appear in the journal.
- Sandbox the service (reference, freedesktop.org, 35 min)
Finish by adding User=, ProtectSystem= and PrivateTmp= so a compromised service can reach less of the host.