TL;DR
After editing a unit, run systemctl daemon-reload. Tail logs with journalctl -u service -f. Use systemctl is-active service in scripts.
Service Control
| Action | Command |
|---|
| Start | systemctl start name |
| Stop | systemctl stop name |
| Restart | systemctl restart name |
| Reload config | systemctl reload name |
| Enable on boot | systemctl enable --now name |
| Disable | systemctl disable name |
| Status | systemctl status name |
| Script check | systemctl is-active name |
Configuration
| Action | Command |
|---|
| Reload units | systemctl daemon-reload |
| View unit | systemctl cat name |
| Edit override | systemctl edit name |
| Unit dirs | /etc/systemd/system/, /lib/systemd/system/ |
Logs
| Action | Command |
|---|
| Service logs | journalctl -u name |
| Follow | journalctl -u name -f |
| Last N lines | journalctl -u name -n 50 |
| Since | journalctl --since "1 hour ago" |
Common Pitfalls
- A NAMESPACE error on reload may leave the process healthy; try the app's own admin API for hot reload.
- "active (running)" vs "exited" are both normal; check the Sub state.
Sources
- systemd docs (freedesktop.org/software/systemd)
最后更新:2026-08-02