systemd 常用命令速查

常用命令

systemctl status app
systemctl start app
systemctl stop app
systemctl restart app
systemctl reload app
systemctl enable app
systemctl disable app
systemctl enable --now app
systemctl is-active app
systemctl is-enabled app
systemctl daemon-reload
systemctl list-units --failed
systemctl list-unit-files
systemctl cat app
systemctl edit app
systemctl show app
journalctl -u app -f
journalctl -u app --since '1 hour ago'
journalctl -p err -b
systemd-analyze blame
systemd-analyze critical-chain

场景速查

目的 命令
查看依赖 systemctl list-dependencies app
查看定时器 systemctl list-timers
查看 target systemctl get-default / set-default
重载单个 unit systemctl reload-or-restart app
临时屏蔽 systemctl mask app / unmask app
查看日志占用 journalctl --disk-usage
清理日志 journalctl --vacuum-size=500M
启动耗时 systemd-analyze blame

易错点

相关命令