systemctl Cheat Sheet
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
| Command | What it does |
|---|---|
sudo systemctl start name | Start a unit now |
sudo systemctl stop name | Stop it now |
sudo systemctl restart name | Stop then start |
sudo systemctl try-restart name | Restart only if it is already running |
sudo systemctl reload name | Re-read config without restarting (if the service supports it) |
sudo systemctl reload-or-restart name | Reload if possible, otherwise restart |
sudo systemctl kill name | Send SIGTERM to all processes of the unit |
sudo systemctl kill -s SIGKILL name | Force-kill a hung service |
sudo systemctl reset-failed name | Clear the failed state and start-rate counter |
sudo systemctl start a b c | Act on several units at once |
Enable at boot
| Command | What it does |
|---|---|
sudo systemctl enable name | Start at boot (creates symlinks per the [Install] section) |
sudo systemctl enable --now name | Enable and start immediately |
sudo systemctl disable name | Don't start at boot |
sudo systemctl disable --now name | Disable and stop immediately |
sudo systemctl mask name | Make the unit impossible to start |
sudo systemctl unmask name | Undo mask |
sudo systemctl reenable name | Disable and enable again (after changing [Install]) |
systemctl is-enabled name | Prints enabled, disabled, static, masked… |
Status and inspection
| Command | What it does |
|---|---|
systemctl status name | State, main PID, memory, last log lines |
systemctl status name -l --no-pager | Full lines, no pager (good for pasting) |
systemctl is-active name | Prints active / inactive / failed; exit code 0 if active |
systemctl is-failed name | Exit code 0 if the unit failed |
systemctl cat name | Show the unit file and all drop-ins in effect |
systemctl show name | All properties, machine-readable |
systemctl show name -p MainPID,ActiveState,Restart | Selected properties only |
systemctl list-dependencies name | What the unit pulls in |
systemctl list-dependencies --reverse name | What depends on the unit |
systemd-analyze verify /etc/systemd/system/app.service | Check a unit file for errors |
systemd-analyze security name | Score 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
| Command | What it does |
|---|---|
systemctl | All loaded and active units (same as list-units) |
systemctl --failed | Units in the failed state |
systemctl list-units --type=service | Loaded services |
systemctl list-units --type=service --state=running | Running services only |
systemctl list-units --all | Include inactive units |
systemctl list-unit-files --type=service | Every installed service with its enable state |
systemctl list-unit-files --state=enabled | Everything that starts at boot |
systemctl list-units 'docker*' | Filter by a glob pattern |
systemctl list-sockets | Socket-activated units and their listening addresses |
systemctl list-timers --all | Timers 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.
| Command | What it does |
|---|---|
sudo systemctl edit name | Create or edit a drop-in override.conf (only override what you change) |
sudo systemctl edit --full name | Copy the whole unit to /etc/systemd/system/ and edit it |
sudo systemctl edit --force --full new.service | Create a brand-new unit file |
sudo systemctl revert name | Remove your overrides and go back to the vendor unit |
sudo systemctl daemon-reload | Reload unit files after editing them by hand |
systemd-delta | List all overridden and extended units on the system |
sudo SYSTEMD_EDITOR=vim systemctl edit name | Choose the editor (or set EDITOR) |
Targets, power and system state
| Command | What it does |
|---|---|
systemctl get-default | Boot target (graphical.target or multi-user.target) |
sudo systemctl set-default multi-user.target | Boot to text mode (no desktop) |
sudo systemctl isolate multi-user.target | Switch to a target now (stops the desktop) |
sudo systemctl rescue | Single-user rescue mode |
sudo systemctl emergency | Emergency shell (see You are in emergency mode) |
sudo systemctl reboot / poweroff | Reboot or power off |
systemctl suspend / hibernate | Sleep states |
sudo systemctl soft-reboot | Restart userspace without rebooting the kernel |
systemctl is-system-running | running, degraded (some unit failed), starting… |
User services and remote hosts
| Command | What it does |
|---|---|
systemctl --user status name | Manage your own per-user units (no sudo) |
systemctl --user enable --now name | Enable a unit from ~/.config/systemd/user/ |
systemctl --user restart pipewire wireplumber | Restart the user audio stack |
sudo loginctl enable-linger alice | Keep alice's user services running when she is logged out |
systemctl -H user@host status nginx | Query 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.
enableonly affects the next boot. Useenable --nowor follow it withstart. - Forgot daemon-reload. After editing a unit file directly, systemctl warns "unit file changed on disk". Run
sudo systemctl daemon-reloadbefore restarting. - Clearing a list setting in a drop-in. To replace
ExecStartin an override you must first empty it with a blankExecStart=line, then set the new value; otherwise systemd complains about multiple ExecStart lines. - Unit names differ between distros. SSH is
sshon Debian/Ubuntu andsshdelsewhere; Apache isapache2on Debian/Ubuntu andhttpdon Fedora/openSUSE. Usesystemctl 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. --userneeds a user session. Throughsudoorsuthere is often no user bus; log in as that user, or usesystemctl --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.