systemctl Cheat Sheet

Most used
systemctl status nginx                 # is it running? recent log lines
sudo systemctl restart nginx           # restart now
sudo systemctl enable --now nginx      # start now and at every boot
systemctl --failed                     # what is broken?
sudo systemctl edit nginx              # override settings with a drop-in
journalctl -u nginx -e                 # full logs for the unit

systemctl controls systemd, the init system and service manager on Ubuntu, Debian, Fedora, Arch, openSUSE and Mint. Read-only commands work as a normal user; changing state needs sudo. The .service suffix is optional for services. For the concepts behind units and targets, see the systemd basics guide.

Start, stop and restart

CommandWhat it does
sudo systemctl start nameStart a unit now
sudo systemctl stop nameStop it now
sudo systemctl restart nameStop then start
sudo systemctl try-restart nameRestart only if it is already running
sudo systemctl reload nameRe-read config without restarting (if the service supports it)
sudo systemctl reload-or-restart nameReload if possible, otherwise restart
sudo systemctl kill nameSend SIGTERM to all processes of the unit
sudo systemctl kill -s SIGKILL nameForce-kill a hung service
sudo systemctl reset-failed nameClear the failed state and start-rate counter
sudo systemctl start a b cAct on several units at once

Enable at boot

CommandWhat it does
sudo systemctl enable nameStart at boot (creates symlinks per the [Install] section)
sudo systemctl enable --now nameEnable and start immediately
sudo systemctl disable nameDon't start at boot
sudo systemctl disable --now nameDisable and stop immediately
sudo systemctl mask nameMake the unit impossible to start
sudo systemctl unmask nameUndo mask
sudo systemctl reenable nameDisable and enable again (after changing [Install])
systemctl is-enabled namePrints enabled, disabled, static, masked…

Status and inspection

CommandWhat it does
systemctl status nameState, main PID, memory, last log lines
systemctl status name -l --no-pagerFull lines, no pager (good for pasting)
systemctl is-active namePrints active / inactive / failed; exit code 0 if active
systemctl is-failed nameExit code 0 if the unit failed
systemctl cat nameShow the unit file and all drop-ins in effect
systemctl show nameAll properties, machine-readable
systemctl show name -p MainPID,ActiveState,RestartSelected properties only
systemctl list-dependencies nameWhat the unit pulls in
systemctl list-dependencies --reverse nameWhat depends on the unit
systemd-analyze verify /etc/systemd/system/app.serviceCheck a unit file for errors
systemd-analyze security nameScore a service's sandboxing options

When status shows failed or a start command prints Job for X.service failed, the reason is in the journal: see the journalctl cheat sheet.

Listing units

CommandWhat it does
systemctlAll loaded and active units (same as list-units)
systemctl --failedUnits in the failed state
systemctl list-units --type=serviceLoaded services
systemctl list-units --type=service --state=runningRunning services only
systemctl list-units --allInclude inactive units
systemctl list-unit-files --type=serviceEvery installed service with its enable state
systemctl list-unit-files --state=enabledEverything that starts at boot
systemctl list-units 'docker*'Filter by a glob pattern
systemctl list-socketsSocket-activated units and their listening addresses
systemctl list-timers --allTimers with last and next run times

Editing unit files

Unit files shipped by packages live in /usr/lib/systemd/system/ (or /lib/systemd/system/). Never edit them; package updates overwrite them. Put your changes in /etc/systemd/system/, which takes precedence.

CommandWhat it does
sudo systemctl edit nameCreate or edit a drop-in override.conf (only override what you change)
sudo systemctl edit --full nameCopy the whole unit to /etc/systemd/system/ and edit it
sudo systemctl edit --force --full new.serviceCreate a brand-new unit file
sudo systemctl revert nameRemove your overrides and go back to the vendor unit
sudo systemctl daemon-reloadReload unit files after editing them by hand
systemd-deltaList all overridden and extended units on the system
sudo SYSTEMD_EDITOR=vim systemctl edit nameChoose the editor (or set EDITOR)

Targets, power and system state

CommandWhat it does
systemctl get-defaultBoot target (graphical.target or multi-user.target)
sudo systemctl set-default multi-user.targetBoot to text mode (no desktop)
sudo systemctl isolate multi-user.targetSwitch to a target now (stops the desktop)
sudo systemctl rescueSingle-user rescue mode
sudo systemctl emergencyEmergency shell (see You are in emergency mode)
sudo systemctl reboot / poweroffReboot or power off
systemctl suspend / hibernateSleep states
sudo systemctl soft-rebootRestart userspace without rebooting the kernel
systemctl is-system-runningrunning, degraded (some unit failed), starting…

User services and remote hosts

CommandWhat it does
systemctl --user status nameManage your own per-user units (no sudo)
systemctl --user enable --now nameEnable a unit from ~/.config/systemd/user/
systemctl --user restart pipewire wireplumberRestart the user audio stack
sudo loginctl enable-linger aliceKeep alice's user services running when she is logged out
systemctl -H user@host status nginxQuery another machine over SSH

Common recipes

Create a simple service for your own script:

sudo systemctl edit --force --full myapp.service
[Unit]
Description=My app
After=network-online.target
Wants=network-online.target

[Service]
User=myapp
ExecStart=/opt/myapp/run.sh
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
sudo systemctl enable --now myapp
systemctl status myapp

Raise a service's open-file limit (a common fix for Too many open files):

sudo systemctl edit nginx
# add:
#   [Service]
#   LimitNOFILE=65535
sudo systemctl restart nginx
systemctl show nginx -p LimitNOFILE

Find and fix every failed unit after boot:

systemctl --failed
journalctl -b -u failed-unit-name --no-pager | tail -50
sudo systemctl reset-failed

Make a service restart automatically when it crashes:

sudo systemctl edit myapp
#   [Service]
#   Restart=always
#   RestartSec=3

Find which service owns a process or a port:

systemctl status 1234          # by PID
sudo ss -tlnp | grep ':80 '    # PID of the listener, then systemctl status PID

Replace a cron job with a timer: see cron vs systemd timers or convert a line automatically with the cron to systemd timer converter.

Gotchas

  • Enabled is not running. enable only affects the next boot. Use enable --now or follow it with start.
  • Forgot daemon-reload. After editing a unit file directly, systemctl warns "unit file changed on disk". Run sudo systemctl daemon-reload before restarting.
  • Clearing a list setting in a drop-in. To replace ExecStart in an override you must first empty it with a blank ExecStart= line, then set the new value; otherwise systemd complains about multiple ExecStart lines.
  • Unit names differ between distros. SSH is ssh on Debian/Ubuntu and sshd elsewhere; Apache is apache2 on Debian/Ubuntu and httpd on Fedora/openSUSE. Use systemctl list-unit-files | grep -i name.
  • "static" units can't be enabled. They have no [Install] section and are started by another unit, socket or timer.
  • Start limit hit. A service that crashes repeatedly is blocked with "start request repeated too quickly". Fix the cause, then reset-failed.
  • --user needs a user session. Through sudo or su there is often no user bus; log in as that user, or use systemctl --user -M alice@.

Reference: systemctl(1), systemd.service(5).

Frequently asked questions

What is the difference between systemctl enable and start?

start runs the service now; enable makes it start automatically at boot. systemctl enable --now name does both.

How do I list all running services?

systemctl list-units --type=service --state=running. For every installed service and whether it is enabled, use systemctl list-unit-files --type=service.

What is the difference between restart and reload?

restart stops and starts the process. reload asks the running process to re-read its configuration without dropping connections, if the service supports it. reload-or-restart picks reload when available.

Do I need daemon-reload after editing a unit file?

Yes, after editing files in /etc/systemd/system/ by hand run sudo systemctl daemon-reload. systemctl edit does it for you.

How do I prevent a service from ever starting?

sudo systemctl mask name links the unit to /dev/null so nothing can start it, not even as a dependency. Undo with unmask.

Spotted a mistake or a command that no longer works? Send a correction — pages are re-checked when reports come in.