systemd Cheatsheet
Quick reference for systemd commands covering service management, unit files, journalctl, timers, targets, systemd-analyze, and sockets
68 commands
systemctl startStart a service
sudo systemctl start nginxsystemctl stopStop a service
sudo systemctl stop nginxsystemctl restartRestart a service
sudo systemctl restart nginxsystemctl reloadReload service configuration
sudo systemctl reload nginxsystemctl statusShow service status
systemctl status nginxsystemctl enableEnable service at boot
sudo systemctl enable nginxsystemctl disableDisable service at boot
sudo systemctl disable nginxsystemctl enable --nowEnable and start service
sudo systemctl enable --now nginxsystemctl is-activeCheck if service is active
systemctl is-active nginxsystemctl is-enabledCheck if service is enabled
systemctl is-enabled nginxsystemctl is-failedCheck if service is failed
systemctl is-failed nginxsystemctl maskMask service to prevent start
sudo systemctl mask nginxsystemctl unmaskUnmask a service
sudo systemctl unmask nginxsystemctl list-unitsList active units
systemctl list-unitssystemctl list-units --type=serviceList service units
systemctl list-units --type=servicesystemctl list-units --failedList failed units
systemctl list-units --failedsystemctl list-unit-filesList all unit files
systemctl list-unit-filessystemctl catShow unit file contents
systemctl cat nginx.servicesystemctl showShow unit properties
systemctl show nginx -p MainPIDsystemctl editEdit unit override
sudo systemctl edit nginxsystemctl edit --fullEdit full unit file
sudo systemctl edit --full nginxsystemctl daemon-reloadReload unit file changes
sudo systemctl daemon-reloadsystemctl list-dependenciesShow unit dependencies
systemctl list-dependencies nginxsystemctl reset-failedReset failed units
sudo systemctl reset-failedjournalctlShow all journal logs
journalctljournalctl -uShow logs for specific unit
journalctl -u nginxjournalctl -fFollow logs in real-time
journalctl -fjournalctl -u -fFollow specific unit logs
journalctl -u nginx -fjournalctl --sinceShow logs since specific time
journalctl --since '2024-01-01 00:00:00'journalctl --since --untilShow logs in time range
journalctl --since '1 hour ago' --until 'now'journalctl -pFilter logs by priority
journalctl -p errjournalctl -bShow logs from current boot
journalctl -bjournalctl -b -1Show logs from previous boot
journalctl -b -1journalctl --disk-usageShow journal disk usage
journalctl --disk-usagejournalctl --vacuum-sizeVacuum journal to size limit
sudo journalctl --vacuum-size=500Mjournalctl --vacuum-timeVacuum journal older than time
sudo journalctl --vacuum-time=30djournalctl -o jsonOutput logs in JSON format
journalctl -u nginx -o json-prettysystemctl list-timersList active timers
systemctl list-timerssystemctl list-timers --allList all timers
systemctl list-timers --allsystemctl start timerStart a timer
sudo systemctl start backup.timersystemctl stop timerStop a timer
sudo systemctl stop backup.timersystemctl enable timerEnable timer at boot
sudo systemctl enable backup.timersystemd-run --on-calendarCreate transient timer (calendar)
systemd-run --on-calendar='*-*-* 02:00:00' /usr/bin/backup.shsystemd-run --on-activeRun once after delay
systemd-run --on-active=30m /usr/bin/cleanup.shsystemctl get-defaultShow default target
systemctl get-defaultsystemctl set-defaultSet default target
sudo systemctl set-default multi-user.targetsystemctl isolateSwitch to target
sudo systemctl isolate graphical.targetsystemctl rescueSwitch to rescue mode
sudo systemctl rescuesystemctl emergencySwitch to emergency mode
sudo systemctl emergencysystemctl poweroffPower off the system
sudo systemctl poweroffsystemctl rebootReboot the system
sudo systemctl rebootsystemctl suspendSuspend the system
sudo systemctl suspendsystemd-analyzeAnalyze boot time
systemd-analyzesystemd-analyze blameShow boot time per unit
systemd-analyze blamesystemd-analyze critical-chainShow critical chain of boot
systemd-analyze critical-chainsystemd-analyze plotGenerate SVG boot time plot
systemd-analyze plot > boot.svgsystemd-analyze verifyVerify unit file syntax
systemd-analyze verify myservice.servicesystemd-analyze dotGenerate DOT dependency graph
systemd-analyze dot | dot -Tsvg > deps.svgsystemd-analyze securityAnalyze service security settings
systemd-analyze security nginx.servicesystemd-cglsShow control group hierarchy
systemd-cglssystemd-cgtopShow cgroup resource usage
systemd-cgtopsystemctl list-socketsList socket units
systemctl list-socketssystemctl start socketStart a socket unit
sudo systemctl start myapp.socketloginctl list-sessionsList login sessions
loginctl list-sessionsloginctl list-usersList logged-in users
loginctl list-usershostnamectlShow or set hostname
hostnamectl set-hostname myservertimedatectlShow or set time and timezone
timedatectl set-timezone Asia/TokyolocalectlShow or set locale settings
localectl set-locale LANG=en_US.UTF-8