From cb4a02d9da449bf6340f7f4e35a638ed8b538989 Mon Sep 17 00:00:00 2001 From: jaywcjlove Date: Wed, 9 Nov 2022 07:27:42 +0000 Subject: [PATCH] feat: add `systemd.md` cheatsheet. (#34) 90c9fefa5198957632c6909b0c14f248674cab2a --- docs/systemd.html | 246 ++++++++++++++++++++++++++++++++++++++++++++++ index.html | 2 + 2 files changed, 248 insertions(+) create mode 100644 docs/systemd.html diff --git a/docs/systemd.html b/docs/systemd.html new file mode 100644 index 00000000..07c21339 --- /dev/null +++ b/docs/systemd.html @@ -0,0 +1,246 @@ + + + + +Systemd + & systemd cheatsheet & Quick Reference + + + + + + + +

+Systemd

+

最常用的 Systemd 命令备忘单快速参考

+

命令

+

查看系统信息

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
:--
systemctl list-dependencies显示单元的依赖关系
systemctl list-sockets列出套接字和激活的内容
systemctl list-jobs查看活动的 systemd 作业
systemctl list-unit-files查看单元文件及其状态
systemctl list-units显示单位是否已加载/活动
systemctl get-default列出默认目标(如运行级别)
+ +

使用服务

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
:--
systemctl stop service停止正在运行的服务
systemctl start service启动服务
systemctl restart service重新启动正在运行的服务
systemctl reload service重新加载服务中的所有配置文件
systemctl daemon-reload必须运行以重新加载更改的单元文件
systemctl statusservice 查看服务是否正在运行/启用
systemctl --failed显示未能运行的服务
systemctl reset-failed将任何单位从失败状态重置
systemctl enable service使服务在启动时启动
systemctl disable service禁用服务 - 不会在启动时启动
systemctl show service显示服务(或其他单元)的属性
systemctl edit service创建片段以放入单元文件
systemctl edit --full service编辑整个单元文件以进行服务
systemctl -H host status network远程运行任何 systemctl 命令
+ +

改变系统状态

+ + + + + + + + + + + + + + + + + + + + + + + + + +
:--
systemctl reboot重启系统(reboot.target)
systemctl poweroff关闭系统(poweroff.target)
systemctl emergency进入紧急模式(emergency.target)
systemctl default返回默认目标(multi-user.target)
+ +

查看日志消息

+ + + + + + + + + + + + + + + + + + + + + + + + + +
:--
journalctl显示所有收集的日志消息
journalctl -u network.service查看网络服务消息
journalctl -f关注出现的消息
journalctl -k仅显示内核消息
+ +

另见

+ +
+ diff --git a/index.html b/index.html index 99c5e74b..9b89eed0 100644 --- a/index.html +++ b/index.html @@ -341,6 +341,8 @@ Sed + +Systemd SSH