Lesson 9.5: Services with systemd and journalctl
What a service is and how systemd manages it: units and unit files, systemctl status and how to read it, start, stop, restart and reload, enable and disable at boot, reading a service's log with journalctl, and troubleshooting a service that fails to start.
22 min
You will learn to
- Explain services, units and unit files
- Read systemctl status
- Start, stop and restart a service with sudo
- Explain the difference between running now (start) and starting at boot (enable)
- Read a service's log with journalctl -u
- Find and fix why a service fails
Key terms
- Service
- A long-running background program managed by the system, such as sshd or cron.
- systemd
- The init system and service manager of most current distributions, PID 1. It starts services in order at boot, supervises them and collects their logs.
- Unit and unit file
- Everything systemd manages is a unit (cron.service, ssh.socket, timers…). A unit file describes it: what to run, as which user, after what, and when to restart.
- start / stop vs enable / disable
- start and stop change what runs now; enable and disable change what starts at boot. They are independent.
- Journal
- systemd's central log (systemd-journald). Every service's output and status changes land there; journalctl reads it.
- journalctl options
- -u UNIT one service · -n N last N lines · -f follow live (Ctrl+C to stop) · -p err only errors · --since today · -e jump to the end · -k kernel messages.
← Foreground and background jobs · All lessons · Scheduling tasks with cron →