systemd cheatsheet
Service control
| Command | Description |
|---|---|
systemctl start nginx | Start a service now |
systemctl stop nginx | Stop a service |
systemctl restart nginx | Stop then start |
systemctl reload nginx | Reload config (if supported) |
systemctl status nginx | State, PID, recent log lines |
systemctl enable nginx | Start at boot |
systemctl disable nginx | Do not start at boot |
systemctl is-active nginx | Print active/inactive (scripts) |
systemctl is-enabled nginx | Print enabled/disabled |
Listing units
| Command | Description |
|---|---|
systemctl list-units --type=service | Loaded services |
systemctl --failed | All failed units (triage) |
systemctl list-units --state=failed | Same, explicit filter |
systemctl reset-failed | Clear failed state after fix |
systemctl list-unit-files | All installed unit files |
systemctl list-timers --all | Active and inactive timers |
systemctl show nginx | All properties of a unit |
Journal logs
| Command | Description |
|---|---|
journalctl -u nginx | Logs for a unit |
journalctl -u nginx -f | Follow unit logs |
journalctl -u nginx --since today | Logs since midnight |
journalctl -b | Logs from current boot |
journalctl -p err -b | Error-level messages this boot |
journalctl --disk-usage | Journal space used |
Unit file management
| Command | Description |
|---|---|
systemctl cat nginx | Show effective unit file |
systemctl edit nginx | Create drop-in override |
systemctl daemon-reload | Reload unit files after changes |
systemd-analyze verify my.service | Validate unit syntax |
Boot analysis
| Command | Description |
|---|---|
systemd-analyze | Total boot time |
systemd-analyze blame | Time per unit at boot |
systemctl get-default | Current default target |
systemctl isolate rescue.target | Switch to rescue target |
Minimal service unit example
# /etc/systemd/system/myapp.service
[Unit]
Description=My Application
After=network.target
[Service]
Type=simple
User=deploy
ExecStart=/opt/myapp/bin/server
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Pro tips
- Always run
systemctl daemon-reloadafter editing unit files systemctl statusshows the last few log lines — usejournalctl -ufor full historyenabledoes not start;startdoes not enable — set both for production- Use
systemctl editinstead of editing files under/usr/lib/systemd/
Practice scenarios
Hands-on systemd scenarios on live Linux VMs: systemd