Services beheren
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl reload nginx config herladen zonder herstart
systemctl status nginx status + recente logs
systemctl enable nginx starten bij boot
systemctl disable nginx
systemctl enable --now nginx enable + start tegelijk
Inspecteren
systemctl list-units --type=service actieve services
systemctl list-units --state=failed gefaalde
systemctl is-active nginx
systemctl is-enabled nginx
systemctl cat nginx unit-bestand tonen
systemctl daemon-reload na unit-wijziging
Logs (journalctl)
journalctl -u nginx logs van één service
journalctl -u nginx -f live volgen
journalctl -u nginx --since "1 hour ago"
journalctl --since today
journalctl -b sinds laatste boot (-b -1 = vorige)
journalctl -p err alleen errors (0-7, emerg→debug)
journalctl -n 50 laatste 50 regels
journalctl --disk-usage
journalctl --vacuum-time=7d ouder dan 7 dagen wissen
Unit-bestand (voorbeeld)
[Unit]
Description=Mijn app
After=network.target
[Service]
ExecStart=/usr/bin/myapp
Restart=on-failure
User=app
[Install]
WantedBy=multi-user.target
Plaats in /etc/systemd/system/, dan daemon-reload en enable --now.