DevOpsil
Systemd44 commands

Systemd Cheat Sheet

Essential systemd commands for managing services, timers, journals, boot targets, and unit files.

Service Management

CommandDescription
sudo systemctl start <service>
Start a service
sudo systemctl stop <service>
Stop a service
sudo systemctl restart <service>
Restart a service
sudo systemctl reload <service>
Reload config without restart
sudo systemctl enable <service>
Enable service at boot
sudo systemctl disable <service>
Disable service at boot
systemctl status <service>
Show service status
systemctl is-active <service>
Check if running
systemctl is-enabled <service>
Check if enabled at boot

Listing & Inspection

CommandDescription
systemctl list-units --type=service
List all loaded services
systemctl list-units --type=service --state=running
List running services
systemctl list-units --failed
List failed units
systemctl list-unit-files --type=service
List all service files
systemctl cat <service>
Show unit file contents
systemctl show <service>
Show all service properties
systemctl list-dependencies <service>
Show dependency tree

Journalctl (Logs)

CommandDescription
journalctl -u <service>
View service logs
journalctl -u <service> -f
Follow service logs
journalctl -u <service> --since "1 hour ago"
Logs from last hour
journalctl -u <service> -n 50
Last 50 log lines
journalctl -p err
Show only error messages
journalctl -b
Logs since last boot
journalctl --disk-usage
Check journal disk usage
sudo journalctl --vacuum-size=500M
Limit journal to 500 MB

Timers (Cron Alternative)

CommandDescription
systemctl list-timers
List active timers
systemctl list-timers --all
List all timers
sudo systemctl enable --now <timer>
Enable and start timer
OnCalendar=daily
Timer unit: run daily
OnCalendar=*-*-* 03:00:00
Timer unit: run at 3 AM
OnBootSec=5min
Timer unit: 5 min after boot

Unit File Basics

CommandDescription
sudo systemctl edit --full <service>
Edit unit file
sudo systemctl edit <service>
Create override drop-in
sudo systemctl daemon-reload
Reload after unit file changes
ExecStart=/usr/bin/myapp
Unit: main command to run
Restart=on-failure
Unit: restart policy
RestartSec=5
Unit: delay between restarts
Environment=NODE_ENV=production
Unit: set env variable
WorkingDirectory=/opt/myapp
Unit: working directory

System State

CommandDescription
systemctl get-default
Show default boot target
sudo systemctl set-default multi-user.target
Set CLI-only boot
sudo systemctl isolate rescue.target
Enter rescue mode
systemctl --user list-units
List user-level services
hostnamectl
Show hostname and OS info
timedatectl
Show time and timezone info