Managing services with systemctl
- Version
- unversioned
- Review
- Draft
Summary#
systemctl inspects and controls units managed by systemd, such as services, sockets and timers. Starting a unit and enabling it are separate actions.
Syntax#
systemctl status app.service
systemctl show --property=ActiveState app.service
systemctl list-units --type=service --state=failed
systemctl restart app.service
systemctl enable --now app.service
systemctl daemon-reload
systemctl --user status app.service
Changing system units normally requires administrator authorization. --user addresses the calling user's service manager instead.
Example#
Run this on a host booted with systemd and running the journal service. It reads a single property of that service.
(
set -eu
systemctl --no-pager show --property=ActiveState systemd-journald.service
)
Expected output#
ActiveState=active
Common mistakes#
enable installs the unit's configured activation links, often for startup at boot. Add --now to start it immediately. After editing unit files, run daemon-reload to reread them. Restart separately if needed, since restart stops and starts the service and may interrupt clients. In scripts, use show to read individual properties.
Version applicability#
This entry describes systemd's systemctl. The --now option for enable requires systemd 220 or later.
Sources#
- Attribution
- DevLookup contributors
- License
- CC-BY-4.0