public:it:linux:systemd

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
public:it:linux:systemd [2021/03/12 09:57] oakfirepublic:it:linux:systemd [2023/02/06 15:31] (当前版本) oakfire
行 1: 行 1:
 ====== Systemd ====== ====== Systemd ======
  
-  * [[http://www.ibm.com/developerworks/cn/linux/1407_liuming_init3/index.html|Systemd 的特点和使用]]+  * <del>[[http://www.ibm.com/developerworks/cn/linux/1407_liuming_init3/index.html|Systemd 的特点和使用]]</del>
   * http://www.jinbuguo.com/systemd/systemd.service.html   * http://www.jinbuguo.com/systemd/systemd.service.html
   * http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html   * http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html
 +  * https://www.freedesktop.org/software/systemd/man/systemd.exec.html
 +  * [[https://systemd-by-example.com/|Systemd 示例教程,可在线尝试]]
 +
 +==== Tips ====
 +  * 查看服务依赖: ''systemctl list-dependencies foo.service''
 +  * 查看服务开机启动顺序:''systemd-analyze plot > ~/boot.svg''
 +  * 查看日志:''journalctl'' 指令
 +  * 关于临时目录 [[https://systemd.io/TEMPORARY_DIRECTORIES/|Using /tmp/ and /var/tmp/ Safely]]
 +    * [[https://www.freedesktop.org/software/systemd/man/systemd-tmpfiles.html|systemd-tmpfiles]] 指令
 +    * [[https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html|man tmpfiles.d]] 临时文件增删改查的配置
 +  * Ubuntu18.04 上慎用 ''PrivateTmp=true'',可能会造成服务卸载时自动删除非tmp内容,可能会让服务执行mount失败,原因未知。
 +
 ==== Systemd 命令和 sysvinit 命令的对照表 ==== ==== Systemd 命令和 sysvinit 命令的对照表 ====
  
-<WRAP tablewidth 50% >+<WRAP tablewidth 80% >
 ^Sysvinit 命令 ^Systemd 命令 ^备注 ^Sysvinit 命令 ^Systemd 命令 ^备注
 |service foo start |systemctl start foo.service |用来启动一个服务 (并不会重启现有的)| |service foo start |systemctl start foo.service |用来启动一个服务 (并不会重启现有的)|
行 14: 行 26:
 |service foo condrestart |systemctl condrestart foo.service |如果服务正在运行那么重启它。| |service foo condrestart |systemctl condrestart foo.service |如果服务正在运行那么重启它。|
 |service foo status |systemctl status foo.service |汇报服务是否正在运行。| |service foo status |systemctl status foo.service |汇报服务是否正在运行。|
-|ls /etc/rc.d/init.d/ |systemctl list-unit-files --type=service |用来列出可以启动或停止的服务列表。|+|ls /etc/rc.d/init.d/ |systemctl list-unit-files  --type=service |用来列出可以启动或停止的服务列表。|
 |chkconfig foo on |systemctl enable foo.service |在下次启动时或满足其他触发条件时设置服务为启用| |chkconfig foo on |systemctl enable foo.service |在下次启动时或满足其他触发条件时设置服务为启用|
 |chkconfig foo off |systemctl disable foo.service |在下次启动时或满足其他触发条件时设置服务为禁用| |chkconfig foo off |systemctl disable foo.service |在下次启动时或满足其他触发条件时设置服务为禁用|
 |chkconfig foo |systemctl is-enabled foo.service |用来检查一个服务在当前环境下被配置为启用还是禁用。| |chkconfig foo |systemctl is-enabled foo.service |用来检查一个服务在当前环境下被配置为启用还是禁用。|
-|chkconfig –list |systemctl list-unit-files --type=service |输出在各个运行级别下服务的启用和禁用情况|+|chkconfig –list |systemctl list-unit-files  --type=service |输出在各个运行级别下服务的启用和禁用情况|
 |chkconfig foo –add |systemctl daemon-reload |当您创建新服务文件或者变更设置时使用。| |chkconfig foo –add |systemctl daemon-reload |当您创建新服务文件或者变更设置时使用。|
 |telinit 3 |systemctl isolate multi-user.target (OR systemctl isolate runlevel3.target OR telinit 3) |改变至多用户运行级别。| |telinit 3 |systemctl isolate multi-user.target (OR systemctl isolate runlevel3.target OR telinit 3) |改变至多用户运行级别。|
 </WRAP> </WRAP>
  
  • public/it/linux/systemd.1615514223.txt.gz
  • 最后更改: 2021/03/12 09:57
  • oakfire