feat: add systemd.md cheatsheet. (#34)

This commit is contained in:
jaywcjlove 2022-11-09 15:26:24 +08:00
parent 29f3b971d2
commit 90c9fefa51
3 changed files with 69 additions and 0 deletions

View File

@ -116,6 +116,7 @@ Quick Reference
[Lsof](./docs/lsof.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));--> [Lsof](./docs/lsof.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Netcat](./docs/netcat.md)<!--rehype:style=background: rgb(4 92 135/var(\-\-bg\-opacity));--> [Netcat](./docs/netcat.md)<!--rehype:style=background: rgb(4 92 135/var(\-\-bg\-opacity));-->
[Sed](./docs/sed.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));--> [Sed](./docs/sed.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Systemd](./docs/systemd.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[SSH](./docs/ssh.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));--> [SSH](./docs/ssh.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
[Screen](./docs/screen.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));--> [Screen](./docs/screen.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
[Tmux](./docs/tmux.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));--> [Tmux](./docs/tmux.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->

66
docs/systemd.md Normal file
View File

@ -0,0 +1,66 @@
Systemd
===
最常用的 [Systemd](https://systemd.io/) 命令备忘单快速参考
命令
----
### 查看系统信息
:- | -
:- | -
`systemctl list-dependencies` | 显示单元的依赖关系
`systemctl list-sockets` | 列出套接字和激活的内容
`systemctl list-jobs` | 查看活动的 systemd 作业
`systemctl list-unit-files` | 查看单元文件及其状态
`systemctl list-units` | 显示单位是否已加载/活动
`systemctl get-default` | 列出默认目标(如运行级别)
<!--rehype:className=style-list-->
### 使用服务
<!--rehype:wrap-class=row-span-2-->
:- | -
:- | -
`systemctl stop service` | <red>停止</red>正在运行的服务
`systemctl start service` | 启动服务
`systemctl restart service` | 重新启动正在运行的服务
`systemctl reload service` | 重新加载服务中的所有配置文件
`systemctl daemon-reload` | 必须运行以重新加载更改的单元文件
`systemctl status` | service 查看服务是否正在运行/启用
`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 命令
<!--rehype:className=style-list-->
### 改变系统状态
:- | -
:- | -
`systemctl reboot` | 重启系统reboot.target
`systemctl poweroff` | 关闭系统poweroff.target
`systemctl emergency` | 进入紧急模式emergency.target
`systemctl default` | 返回默认目标multi-user.target
<!--rehype:className=style-list-->
### 查看日志消息
:- | -
:- | -
`journalctl` | 显示所有收集的日志消息
`journalctl -u network.service` | 查看网络服务消息
`journalctl -f` | 关注出现的消息
`journalctl -k` | 仅显示内核消息
<!--rehype:className=style-list-->
另见
---
- [Systemd 官网](https://systemd.io/) _(systemd.io)_
- [Systemd Cheat Sheet](https://access.redhat.com/sites/default/files/attachments/12052018_systemd_6.pdf) _(access.redhat.com)_

View File

@ -0,0 +1,2 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em" viewBox="0 0 86 26">
<path d="M10,0 L10,4 L4,4 L4,22 L10,22 L10,26 L0,26 L0,0 L10,0 Z M86,0 L86,26 L76,26 L76,22 L82,22 L82,4 L76,4 L76,0 L86,0 Z M63,3 L63,23 L45,13 L63,3 Z M30,4 C34.9705627,4 39,8.02943725 39,13 C39,17.9705627 34.9705627,22 30,22 C25.0294373,22 21,17.9705627 21,13 C21,8.02943725 25.0294373,4 30,4 Z"/></svg>

After

Width:  |  Height:  |  Size: 412 B