systemctl is the interface to systemd. Two pairs of verbs do most
of the work: start / stop for runtime, enable / disable for
boot. Understanding the distinction is the foundation of every
operational change.
Start, stop, restart, reload
Service impact possibleruntime verbs— start activates the unit now. stop deactivates it. restart stops then starts. reload tells the service to re-read configuration (only works for services that implement it — sshd does).
runs the unit’s ExecReload=; fails if the unit defines none
nothing
enable
nothing
activates at boot
disable
nothing
deactivates at boot
enable, disable, mask, unmask
Service impact possibleboot verbs— enable creates the symlinks that activate the unit at boot. disable removes them. mask creates a /etc/systemd/system/<unit> symlink to /dev/null, preventing any activation — even by other services. unmask removes the mask.
Read-only / Safesystemctl status— status shows loaded state, active state with sub-state, main PID, task count, memory, CPU time, and the cgroup tree. The Loaded line tells you whether the unit is enabled and whether it is vendor-preset.
$ systemctl status sshd
● sshd.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2026-08-04 11:23:45 UTC; 5 days ago
Main PID: 12345 (sshd)
Tasks: 5 (limit: 23456)
Memory: 12.4M
CPU: 5.230s
CGroup: /system.slice/sshd.service
└─12345 /usr/sbin/sshd -D
...
Illustrative output
Read-only / Safeis-active / is-enabled / is-failed— Three queries that return single words — designed for scripting. is-active returns active/inactive/activating/deactivating/failed. is-enabled returns enabled/disabled/static/enabled-runtime. is-failed prints failed when the unit is in the failed state; otherwise it prints the current active state — which is why a perfectly healthy sshd prints active here.
# Correct: exit 0 means "this unit is in the failed state"if systemctl is-failed --quiet "$unit"; then alert "$unit has failed"fi# WRONG - this alert never fires. A failed unit prints# 'failed', not 'inactive', so the comparison is never true.# It is also silently wrong the other way: a unit that is# merely stopped prints 'inactive' and would alert falsely.if [ "$(systemctl is-failed "$unit")" = "inactive" ]; then alert "$unit has failed"fi
--quiet suppresses the state word so the exit code is the only
output, which is what a check script wants. For the fleet-wide
form, ask systemd for the whole list rather than looping:
Read-only / Safeevery failed unit at once— --no-legend strips the header and summary so each line is one failed unit — an empty output means nothing has failed. Cheaper and less racy than iterating over a hard-coded unit list, and it catches units you forgot to monitor. Bare `systemctl is-failed` with no unit answers the same question for the system as a whole: it reports the degraded state.
$ systemctl list-units --state=failed --no-legend
nginx.service loaded failed failed A high performance web server
Illustrative output
Clearing a failed state with reset-failed
A unit that has failed stays failed. systemd remembers it, and it
also remembers how many times the unit has been started recently.
Exceed the start rate limit — StartLimitBurst starts within
StartLimitIntervalSec, 5 in 10 seconds on a stock system, both
directives living in [Unit] — and systemd refuses every further
start and restart, including the one you issue after fixing
the problem.
Service impact possiblereset-failed then start— reset-failed clears the failed state AND the start rate-limit counter, so the next start is allowed. With no unit argument it clears every failed unit on the host, which is how you get systemctl --failed back to a meaningful list after an incident.
Active: active (running) since Mon 2026-08-10 09:14:02 UTC
Illustrative output
Listing and filtering
Read-only / Safelist-units— list-units shows runtime status of units. list-unit-files shows the on-disk state (enabled/disabled/static) without runtime. --state=failed is the canonical first command after a reboot — it tells you what failed to start.
UNIT LOAD ACTIVE SUB DESCRIPTION
accounts-daemon.service loaded active running Accounts Service
chrony.service loaded active running chrony, an NTP client/server
...
Illustrative output
Production patterns
Read-only / Safepost-boot health check— After a reboot, run this. If any unit is in failed state, the system has a problem. Then `systemctl status <unit>` and `journalctl -xeu <unit>` for diagnostics.
$ systemctl list-units --state=failed --no-pager
0 loaded units listed.
Illustrative output
Read-only / Safereverse deps— --reverse shows what depends ON this unit. Useful when stopping a service — the list tells you what will be affected. runlevel2.target means sshd is part of multi-user.target; many services transitively depend on it.
$ systemctl list-dependencies --reverse sshd
sshd.service
● └─runlevel2.target
...
Illustrative output
Knowledge check
Knowledge check · 5 questions
Q1. What is the difference between `disable` and `mask`?
Q2. A unit that has been enabled but never started will not be running until the next boot.
Q3. Which of the following are correct systemd management practices? Select all that apply.
Q4. A monitoring script contains `if [ "$(systemctl is-failed nginx)" = "inactive" ]; then alert; fi`. nginx has been in the failed state for three days and no alert has fired. Why?
Q5. You are writing a post-deploy gate that must fail the pipeline if anything on the host is broken. Which check is the most reliable?
Passing score: 75%. Answers are checked in this browser.