Systemctl Cheet Sheet
Jump to navigation
Jump to search
systemctl Cheat Sheet
This is a generic `systemctl` cheat sheet using `alloy.service` as the example unit name.
Service Status
systemctl status alloy.service systemctl is-active alloy.service systemctl is-enabled alloy.service
Start, Stop, Restart
systemctl start alloy.service systemctl stop alloy.service systemctl restart alloy.service systemctl reload alloy.service
Enable or Disable at Boot
systemctl enable alloy.service systemctl disable alloy.service systemctl enable --now alloy.service systemctl disable --now alloy.service
Reload Unit Files
systemctl daemon-reload
Use this after changing a unit file in `/etc/systemd/system/`.
View Unit Definition
systemctl cat alloy.service systemctl show alloy.service
Edit a Unit
systemctl edit --full alloy.service systemctl edit alloy.service
Notes:
- `--full` edits the whole unit file
- without `--full`, systemd creates a drop-in override
Remove Overrides
systemctl revert alloy.service
Logs
journalctl -u alloy.service journalctl -u alloy.service -n 50 --no-pager journalctl -u alloy.service -f
Failed Units and Unit Files
systemctl list-units --failed systemctl --failed systemctl list-unit-files
Mask and Unmask
systemctl mask alloy.service systemctl unmask alloy.service
`mask` prevents manual or automatic start.
Dependencies
systemctl list-dependencies alloy.service
Common Workflow After Changing a Service
systemctl daemon-reload systemctl restart alloy.service systemctl status alloy.service journalctl -u alloy.service -n 50 --no-pager
Common Troubleshooting
systemd-analyze verify /etc/systemd/system/alloy.service systemctl cat alloy.service journalctl -xeu alloy.service