Manage services, logs and timers on modern Linux systems (Debian, Ubuntu, Fedora, Raspberry Pi OS and others).
Print or save as PDF
Services
The status of a service
systemctl status name
Start
sudo systemctl start name
Stop
sudo systemctl stop name
Restart
sudo systemctl restart name
Reload the settings without restarting
sudo systemctl reload name
Start at boot
sudo systemctl enable name
No longer start automatically
sudo systemctl disable name
Start now and start automatically
sudo systemctl enable --now name
Is it running?
systemctl is-active name
Does it start at boot?
systemctl is-enabled name
Overviews
All running services
systemctl list-units --type=service --state=running
Failed services
systemctl --failed
All installed service files
systemctl list-unit-files --type=service
Show the service file
systemctl cat name
What starts slowly at boot?
systemd-analyze blame
Custom or modified services
Safely modify a service (override)
sudo systemctl edit name
After changing a file: reload
sudo systemctl daemon-reload
Create your own service file
sudo nano /etc/systemd/system/myservice.service
Services for your own user
systemctl --user status name
Logs (journalctl)
Log of a service
journalctl -u name
Follow along
journalctl -u name -f
Only since this boot
journalctl -b
The past hour
journalctl --since "1 hour ago"
Only errors
journalctl -p err -b
How much space does the log use?
journalctl --disk-usage
Clean up logs older than 7 days
sudo journalctl --vacuum-time=7d
Timers (replacement for cron)
All timers with the next time
systemctl list-timers
Enable a timer
sudo systemctl enable --now name.timer
System
Restart
sudo systemctl reboot
Power off
sudo systemctl poweroff
Good to know
A minimal service file (/etc/systemd/system/myservice.service): [Unit] with Description=My service and After=network.target; [Service] with ExecStart=/path/to/program, Restart=on-failure and User=user; [Install] with WantedBy=multi-user.target. Then daemon-reload and enable --now.
Never modify files in /lib/systemd/system or /usr/lib/systemd/system: they will be overwritten during updates. Use systemctl edit.
Sources and attribution
This overview is compiled in our own words. Commands and options change per version: check the official documentation if in doubt.