Tools › Cheat sheets › System Administration › systemctl
⚙️

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

CommandWhat it does
systemctl start NAMEStart a service now.
systemctl stop NAMEStop a service now.
systemctl restart NAMEStop and start a service.
systemctl reload NAMEAsk the service to reload its configuration without restarting (if supported).
systemctl try-restart NAMERestart only if the service is already running.
systemctl status NAMEShow state, recent log lines and the main process ID.

Enable at boot

CommandWhat it does
systemctl enable NAMEStart the service automatically at boot.
systemctl enable --now NAMEEnable at boot and start it immediately.
systemctl disable NAMEDo not start the service at boot.
systemctl disable --now NAMEDisable at boot and stop it now.
systemctl is-enabled NAMEPrint whether the service starts at boot.
systemctl is-active NAMEPrint whether the service is running (exit code 0 if active).
systemctl mask NAMEMake a unit impossible to start, even by dependency.
systemctl unmask NAMEUndo mask.

Inspect

CommandWhat it does
systemctl list-units --type=serviceList loaded services and their state.
systemctl --failedList units that have failed.
systemctl list-unit-files --type=serviceList installed service files and whether they are enabled.
systemctl list-timersShow scheduled systemd timers and when they next run.
systemctl cat NAMEPrint the unit file including any drop-in overrides.
systemctl show NAME -p MainPIDShow a single property of a unit.
systemctl list-dependencies NAMEShow what a unit depends on.

Edit and reload

CommandWhat it does
systemctl daemon-reloadRe-read unit files after you create or change one.
systemctl edit NAMECreate a drop-in override that survives package updates.
systemctl edit --full NAMEEdit a full copy of the unit file.
systemctl revert NAMERemove overrides and return to the packaged unit.
systemctl reset-failedClear the failed state of all units.

System and boot

CommandWhat it does
systemctl get-defaultShow the default boot target (graphical.target or multi-user.target).
systemctl set-default multi-user.targetBoot to text mode by default.
systemctl rebootReboot the machine.
systemctl poweroffShut the machine down.
systemd-analyze blameList units by how long they took to start at boot.
systemd-analyze critical-chainShow the chain of units that limited boot speed.
systemctl --user status NAMEManage 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.

More System Administration cheat sheets

📜 journalctl📦 apt🎩 dnf / yum👥 Users & groups📊 Processes & performance💽 Disks & storage🔄 rsync⏱️ Cron expressionsAll System Administration cheat sheets →
Copied to clipboard