systemctl #
bash
systemctl list-units [--all] [--type=TYPE] [--state=STATE] [PATTERN...]
systemctl list-unit-files [--state=STATE]
systemctl list-sockets [--show-types] [--all] [--state=STATE] [PATTERN...]
systemctl list-timers [PATTERN...]
systemctl list-jobs [--after] [--before] [PATTERN...]
systemctl list-dependencies [--all] [--reverse] [--after] [--before] [UNIT...]
systemctl show [PATTERN...|JOB...]
systemctl cat PATTERN...
systemctl edit [--system|--user|--runtime|--global] [--full] UNIT...
systemctl status [-all] [--type=TYPE] [PATTERN...|PID...]
systemctl is-active PATTERN...
systemctl is-failed PATTERN...
systemctl is-enabled UNIT...
systemctl start PATTERN...
systemctl stop PATTERN...
systemctl kill [-s SIGNAL] PATTERN...
systemctl reload PATTERN...
systemctl restart PATTERN...
systemctl reload-or-restart PATTERN...
systemctl try-restart PATTERN...
systemctl try-reload-or-restart PATTERN...
systemctl daemon-reload
systemctl enable [--system|--user|--runtime|--global] [--now] UNIT...|PATH...
systemctl disable [--system|--user|--runtime|--global] [--now] UNIT...
systemctl preset UNIT...
systemctl mask [--now] UNIT...
systemctl unmask UNIT...
systemctl link UNIT...
systemctl add-wants TARGET UNIT...
systemctl add-requires TARGET UNIT...
systemctl get-default
systemctl set-default TARGET
systemctl halt
systemctl poweroff
systemctl reboot
systemctl suspend
systemctl hibernate
text
# is-enabled result:
[ExitCode=0] enabled / enabled-runtime / linked / linked-runtime / alias / static / indirect / generated / transient
[ExitCode>0] disabled / masked / masked-runtime / bad
Examples #
bash
# 查看所有可能的类型
systemctl --type=help
# 查看所有可能的状态
systemctl --state=help
# 查看已启用的服务
systemctl list-unit-files --state=enabled
# 查看启动失败的服务
systemctl --failed
systemctl --state=failed
# 查看服务脚本内容
systemctl cat unit-name