⚙️
systemctl cheat sheet
systemctl is the command-line interface to systemd, the init system on most modern Linux distributions. Replace NAME with a unit such as nginx (the .service suffix is optional). Most commands that change state need root, so prefix them with sudo.
Click any command to copy it.
Start, stop and restart
| Command | What it does |
|---|---|
systemctl start NAME | Start a service now. |
systemctl stop NAME | Stop a service now. |
systemctl restart NAME | Stop and start a service. |
systemctl reload NAME | Ask the service to reload its configuration without restarting (if supported). |
systemctl try-restart NAME | Restart only if the service is already running. |
systemctl status NAME | Show state, recent log lines and the main process ID. |
Enable at boot
| Command | What it does |
|---|---|
systemctl enable NAME | Start the service automatically at boot. |
systemctl enable --now NAME | Enable at boot and start it immediately. |
systemctl disable NAME | Do not start the service at boot. |
systemctl disable --now NAME | Disable at boot and stop it now. |
systemctl is-enabled NAME | Print whether the service starts at boot. |
systemctl is-active NAME | Print whether the service is running (exit code 0 if active). |
systemctl mask NAME | Make a unit impossible to start, even by dependency. |
systemctl unmask NAME | Undo mask. |
Inspect
| Command | What it does |
|---|---|
systemctl list-units --type=service | List loaded services and their state. |
systemctl --failed | List units that have failed. |
systemctl list-unit-files --type=service | List installed service files and whether they are enabled. |
systemctl list-timers | Show scheduled systemd timers and when they next run. |
systemctl cat NAME | Print the unit file including any drop-in overrides. |
systemctl show NAME -p MainPID | Show a single property of a unit. |
systemctl list-dependencies NAME | Show what a unit depends on. |
Edit and reload
| Command | What it does |
|---|---|
systemctl daemon-reload | Re-read unit files after you create or change one. |
systemctl edit NAME | Create a drop-in override that survives package updates. |
systemctl edit --full NAME | Edit a full copy of the unit file. |
systemctl revert NAME | Remove overrides and return to the packaged unit. |
systemctl reset-failed | Clear the failed state of all units. |
System and boot
| Command | What it does |
|---|---|
systemctl get-default | Show the default boot target (graphical.target or multi-user.target). |
systemctl set-default multi-user.target | Boot to text mode by default. |
systemctl reboot | Reboot the machine. |
systemctl poweroff | Shut the machine down. |
systemd-analyze blame | List units by how long they took to start at boot. |
systemd-analyze critical-chain | Show the chain of units that limited boot speed. |
systemctl --user status NAME | Manage services belonging to your own user session. |
Frequently asked questions
What is the difference between restart and reload?
restart stops and starts the service, dropping connections. reload asks the running process to re-read its configuration, which most web servers support without downtime.
What does enable do compared with start?
start runs the service now; enable makes it start at boot. Use enable --now for both.