When to use systemctl
Use systemctl to inspect services managed by systemd. Read status and unit configuration before changing state, and distinguish a service being active now from being enabled for future boot.
Syntax
systemctl [PARAMETERS] ACTION [UNIT…]Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Check service
systemctl status nginxThe selected unit's current state and recent status information are shown.
Show running services
systemctl list-units --type=service --state=runningLoaded service units currently in the running state are listed.
Show the unit configuration
systemctl cat nginxThe unit's configuration and available drop-in fragments are displayed.
Notes and limitations
- restart can terminate current connections; Before restarting, check the service configuration.
- systemctl is designed for a system with systemd; in a container without it, the system bus may not be accessible.
Common questions and troubleshooting
Does enabled mean the service is running?
For systemd services, enabled configures startup behaviour. The active state describes current runtime activity. Check both properties when diagnosing a service.
Why is systemctl unavailable in a container?
The environment may not run systemd as its service manager. Use the container or host's actual supervision mechanism.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man systemctl.