rmdir.cn
命令速查/systemd
🧩

systemd

systemctl 服务管理、单元与定时器

服务管理

7 条

启动一个已配置的单元

systemctl start 单元名

停止运行中的单元

systemctl stop 单元名

重新启动单元

systemctl restart 单元名

不中断进程地重新加载配置

systemctl reload 单元名

查看单元状态与最近日志

systemctl status 单元名 [--no-pager] [--full]

建立开机自启链接

systemctl enable [--now] 单元名

取消开机自启链接

systemctl disable [--now] 单元名

单元文件与排查

6 条

让 systemd 重新读取单元文件

sudo systemctl daemon-reload

查看单元文件及其覆盖片段

systemctl cat 单元名

创建单元文件的覆盖片段

systemctl edit [--full] 单元名

静态检查单元文件语法与字段

systemd-analyze verify 单元文件路径

按类型和状态筛选单元

systemctl list-units [--type=service] [--state=failed] [--all]

按单元过滤日志

journalctl -u 单元名 [-n 行数] [--since 时间] [-f]

定时器

2 条

校验并预览 OnCalendar 表达式

systemd-analyze calendar '表达式'

列出定时器与下次触发时间

systemctl list-timers [--all] [--no-pager]