Skip to content

systemctl Command Cheat Sheet

systemctl is the central management tool for controlling the init system (systemd).


Synopsis

systemctl [OPTIONS...] COMMAND [UNIT...]

Service Management

Start/Stop/Restart

sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx

Enable/Disable Boot Start

sudo systemctl enable nginx
sudo systemctl disable nginx
Enable links the service file to the boot target.

Check Status

systemctl status nginx
Shows: Loaded state, Active state, Main PID, and recent logs.

Check if Active/Enabled

systemctl is-active nginx
systemctl is-enabled nginx

Unit Management

List Running Services

systemctl list-units --type=service

List All (Including Inactive)

systemctl list-units --type=service --all

List Failed Units

Find what crashed on boot.

systemctl --failed

System State

Reboot/Poweroff

systemctl reboot
systemctl poweroff
systemctl suspend

Rescue Mode

systemctl rescue

Troubleshooting & Analysis

Edit Service File

Safely edit a service unit override.

sudo systemctl edit nginx
Creates: /etc/systemd/system/nginx.service.d/override.conf.

View Logs

For specific service (wrapper around journalctl).

systemctl status nginx -l

Mask a Service

Completely forbid a service from starting (even manually or by dependency).

sudo systemctl mask nginx
(Unmask with unmask).

Analyze Dependencies

Who needs this service?

systemctl list-dependencies nginx --reverse

Who does this service need?

systemctl list-dependencies nginx

Timers (Cron Alternative)

List active timers.

systemctl list-timers

Notes

  • Daemon Reload: If you manually edit unit files in /lib/systemd/ or /etc/systemd/, you must run:
    sudo systemctl daemon-reload