The systemctl command is the main interface for controlling systemd units.
Units include:
- Services (
.service) - Timers (
.timer) - Sockets (
.socket) - Targets (
.target) - Mounts (
.mount)
Overview
Typical administrative tasks include:
- Starting and stopping services
- Enabling services at boot
- Checking status and failed units
- Reloading configuration
- Managing user and system instances
Syntax
systemctl [command] [unit]
Command Quick Reference
| Command | Purpose |
|---|---|
systemctl status <unit> |
Show service status and recent logs |
systemctl start <unit> |
Start a unit |
systemctl stop <unit> |
Stop a unit |
systemctl restart <unit> |
Restart a unit |
systemctl reload <unit> |
Reload configuration without full restart (if supported) |
systemctl enable <unit> |
Enable at boot |
systemctl disable <unit> |
Disable at boot |
systemctl is-active <unit> |
Check if running |
systemctl is-enabled <unit> |
Check boot-enable state |
systemctl daemon-reload |
Reload unit files after changes |
systemctl list-units --type=service |
List active service units |
systemctl --failed |
List failed units |
Core Workflows
Inspect Service State
sudo systemctl status ssh
systemctl is-active ssh
systemctl is-enabled ssh
Start, Stop, Restart
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
Reload Config and Unit Definitions
sudo systemctl reload nginx
sudo systemctl daemon-reload
Use daemon-reload after modifying files in /etc/systemd/system.
Enable or Disable on Boot
sudo systemctl enable nginx
sudo systemctl disable nginx
View Failed Units
systemctl --failed
Useful Options
| Option | Meaning |
|---|---|
--type=service |
Restrict unit listing to services |
--all |
Include inactive units in lists |
--no-pager |
Print full output without pager |
--user |
Operate on user-level units |
-l |
Show full lines without truncation |
Examples
sudo systemctl status ssh
sudo systemctl restart docker
systemctl list-units --type=service --all
Troubleshooting
Unit Not Found
- Confirm unit name with
systemctl list-unit-files | grep <name>. - If you added a new unit file, run
sudo systemctl daemon-reload. - Use fully qualified unit names when needed (example:
nginx.service).
Service Fails to Start
Check details with:
sudo systemctl status <unit>
sudo journalctl -u <unit> -n 200 --no-pager
Enable Fails Due to Missing Install Section
Unit file may not include an [Install] section, or may not be designed for enabling.
Best Practices
- Prefer
systemctlfor service lifecycle control over manual process killing. - Use
reloadwhen possible to avoid unnecessary downtime. - Check
statusand related journal logs after changes. - Run
daemon-reloadafter any unit file edits. - Use
is-activeandis-enabledin health checks and scripts.
Related Commands
journalctl: Inspect service logs from systemd journalps: Process-level inspectionkillandpkill: Direct process signaling