systemctl
Overview
systemctl is the primary interface to systemd: start/stop units, enable on boot, inspect status, and list dependencies. Ubuntu, Debian, Fedora, and RHEL-family systems all use it for service control.
Syntax
systemctl [options] command [unit...]Units use suffixes: .service, .socket, .timer, .mount, .target, .path, …
Common Commands
| Command | Description |
|---|---|
status UNIT |
State, PIDs, recent journal snippet |
start / stop / restart / reload |
Lifecycle |
enable / disable |
Boot linkage |
enable --now |
Enable and start |
is-active / is-enabled / is-failed |
Script-friendly checks |
mask / unmask |
Block start entirely / undo |
daemon-reload |
Reload unit files after edits |
list-units / list-unit-files |
Inventory |
list-timers / list-sockets |
Timers / sockets |
cat UNIT |
Show unit text (incl. drop-ins) |
edit UNIT |
Create drop-in override |
show UNIT |
Low-level properties |
reset-failed |
Clear failed state |
reboot / poweroff / suspend |
System actions |
Key Use Cases
- Operate application and infrastructure services
- Enable services at boot
- Debug failed units
- Override vendor unit settings safely with drop-ins
- Inspect timers as a cron alternative
Safety
masksymlinks a unit to/dev/null— easy to forget; preferstop+disableunless you must block activation.
- Do not
restartremote access (ssh.service) on a fleet without console/recovery.
daemon-reloadafter every unit file change — forgetting it is a common footgun.
- User vs system buses:
systemctl --useris a separate world.
Examples with Explanations
Status and logs peek
systemctl status nginx --no-pager -l
journalctl -u nginx -n 50 --no-pagerStart / enable
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl enable --now nginxRestart vs reload
sudo systemctl reload nginx # graceful if ExecReload defined
sudo systemctl restart nginx
sudo systemctl try-restart nginx # only if already activeFailed units
systemctl --failed
systemctl list-units --state=failed
sudo systemctl reset-failedScript checks
systemctl is-active --quiet nginx && echo running
systemctl is-enabled nginx
systemctl is-failed nginxAfter editing unit files
sudo systemctl daemon-reload
sudo systemctl restart myapp.serviceDrop-in override (preferred over editing vendor files)
sudo systemctl edit nginx.service
# creates /etc/systemd/system/nginx.service.d/override.conf
sudo systemctl cat nginx.serviceExample override snippet:
[Service]
Environment=GOMAXPROCS=4
LimitNOFILE=65535Timers (cron alternative)
systemctl list-timers --all
systemctl status logrotate.timer
systemctl cat logrotate.timerDependencies and reverse deps
systemctl list-dependencies nginx.service
systemctl list-dependencies --reverse nginx.serviceUser services
systemctl --user status podman.socket
loginctl enable-linger "$USER" # allow user services without loginIsolate targets (careful)
systemctl get-default
# sudo systemctl isolate multi-user.target # stops graphical stack, etc.Understanding Output
status shows load state (loaded/masked), active state (running/failed/dead), main PID, cgroup path, and a journal snippet. is-active / is-enabled exit codes are designed for shell scripts (0 = true for the asked condition).
Notes & Pitfalls
- Unit names can be abbreviated when unique (
systemctl status nginx).
restartis stop+start; open files/sockets may behave differently thanreload.
- Template units:
systemctl start getty@tty2instantiatesgetty@.service.
- Masked units look “disabled” but refuse start until
unmask.
- Containers may run without systemd — commands then fail or talk to the host via bind mounts.
Additional Resources
man systemctl
man systemd.service
man systemd.timer