DE EN IT

~/cheat-sheets / systemctl

systemctl cheat sheet

Field-tested systemd commands for everyday admin work – searchable and copyable in one click. Units, timers, overrides and boot analysis.

37 commands

Status & control

  • State and latest log lines of a unit

    systemctl status nginx
  • Start a unit

    sudo systemctl start nginx
  • Stop a unit

    sudo systemctl stop nginx
  • Stop and start a unit again

    sudo systemctl restart nginx
    ⚠ Careful: changes or deletes data
  • Reload the config without stopping

    sudo systemctl reload nginx
  • Short state: active, inactive or failed

    systemctl is-active nginx
  • Check whether the unit starts at boot

    systemctl is-enabled nginx

Autostart & masking

  • Enable autostart at boot

    sudo systemctl enable nginx
  • Enable autostart and start now

    sudo systemctl enable --now nginx
  • Disable autostart

    sudo systemctl disable nginx
  • Fully block a unit (also as dependency)

    sudo systemctl mask nginx
    ⚠ Careful: changes or deletes data
  • Remove the mask

    sudo systemctl unmask nginx
  • Re-read unit files after changes

    sudo systemctl daemon-reload

Finding & inspecting units

  • List all failed units

    systemctl --failed
  • List running services

    systemctl list-units --type=service --state=running
  • Show the unit file including drop-ins

    systemctl cat nginx
  • Dependency tree of a unit

    systemctl list-dependencies nginx

Journal pointers

  • Follow the logs of a unit live

    journalctl -u nginx -f
  • Messages from the last hour

    journalctl -u nginx --since '1 hour ago'
  • Errors since the last boot

    journalctl -b -p err
  • Disk space used by the journal

    journalctl --disk-usage

Timers

  • All timers with next and last run

    systemctl list-timers --all
  • Enable and start a timer

    sudo systemctl enable --now backup.timer
  • Run the matching job once right now

    sudo systemctl start backup.service
  • Timer line: every day at 03:00

    OnCalendar=*-*-* 03:00:00
  • Timer line: catch up on missed runs after boot

    Persistent=true
  • Validate a time expression and show next run

    systemd-analyze calendar 'Mon *-*-* 06:00'

Overrides with drop-ins

  • Create a drop-in (survives package updates)

    sudo systemctl edit nginx
  • Discard all local changes to the unit

    sudo systemctl revert nginx
    ⚠ Careful: changes or deletes data
  • Drop-in [Service]: restart on failure (RestartSec=5 waits 5 s)

    Restart=on-failure
  • Drop-in [Service]: cap memory at 1 GB

    MemoryMax=1G
  • Drop-in [Service]: clear the inherited ExecStart before setting a new one

    ExecStart=

Analysis & targets

  • Show total boot time

    systemd-analyze
  • The 15 slowest units at boot

    systemd-analyze blame | head -n 15
  • Sandboxing score of a unit

    systemd-analyze security nginx
  • Boot without a graphical interface

    sudo systemctl set-default multi-user.target
  • Switch to rescue mode (stops services)

    sudo systemctl isolate rescue.target
    ⚠ Careful: changes or deletes data

New articles by e-mail

One e-mail per new article. No tracking, unsubscribe any time. As a thank-you after confirming: my “Server operations & patching” checklist (PDF).