systemd Cheatsheet

The systemd command set on one page. This pairs with the systemd post — read that for the why, keep this for the how. systemctl is the modern tool; the SysV-era column (service, chkconfig, update-rc.d) is what you will still meet on older boxes with no systemd. Anything that changes state wants sudo. A unit name works with or without the .service suffix.

Manage a service now

TasksystemctlSysV-era
Startsystemctl start NAMEservice NAME start
Stopsystemctl stop NAMEservice NAME stop
Restart (full bounce)systemctl restart NAMEservice NAME restart
Reload config onlysystemctl reload NAMEservice NAME reload
Reload, or restart if it can’tsystemctl reload-or-restart NAME

Start at boot (enable / disable)

TasksystemctlSysV-era
Start at every bootsystemctl enable NAMEchkconfig NAME on / update-rc.d NAME enable
Do not start at bootsystemctl disable NAMEchkconfig NAME off / update-rc.d NAME disable
Enable and start nowsystemctl enable --now NAME
Disable and stop nowsystemctl disable --now NAME
Is it set to start at boot?systemctl is-enabled NAMEchkconfig --list NAME

Check state

TaskCommand
Full status + recent logssystemctl status NAME
Just “is it running?” (script-friendly)systemctl is-active NAME
List running servicessystemctl list-units --type=service
List every installed unit filesystemctl list-unit-files --type=service
Show only what has failedsystemctl --failed

Logs — journalctl

TaskCommand
Everything a service loggedjournalctl -u NAME
Follow live (like tail -f)journalctl -u NAME -f
Just this bootjournalctl -u NAME -b
Since a timejournalctl -u NAME --since "1 hour ago"
Errors and worse onlyjournalctl -u NAME -p err
How much disk the journal usesjournalctl --disk-usage

Unit files

TaskCommand / path
Your own unit files live here/etc/systemd/system/
Package-provided ones live here/lib/systemd/system/
Re-read units after editingsystemctl daemon-reload
Show a unit’s contentssystemctl cat NAME
Add an override (safe)systemctl edit NAME
Edit the whole unitsystemctl edit --full NAME

Targets and power

TaskCommand
Current default targetsystemctl get-default
Boot to console, no GUIsystemctl set-default multi-user.target
Boot to a desktopsystemctl set-default graphical.target
Reboot / power offsystemctl reboot / systemctl poweroff

Warning

On a remote box, never stop or disable the service you are connected through — systemctl stop sshd over SSH locks you straight out. Mind firewalls and networking services the same way. And remember daemon-reload after editing any unit file, or systemd carries on using the old version.