Centos使用Systemctl命令

阅读此文章之前,我们来约定一下:system.service是服务
温馨提示:修改启动脚本之后记得执行systemctl daemon-reload重新加载哦~
1.查看开机启动项

ll /etc/systemd/system/multi-user.target.wants // service(全部)
systemctl list-unit-files (--type=service)     // systemctl(全部)
systemctl list-unit-files | grep enabled       // systemctl(自启动)
chkconfig --list                               // service(安装)
systemctl --failed                             // 查看启动失败的服务

2.system.service命令

systemctl daemon-reload                   // 当新增或修改service单元文件时,需要系统重新加载所有修改过的配置文件
systemctl enable system.service           // 设置为开机自启动
systemctl is-enabled system.service       // 查看服务是否开机启动
systemctl disable system.service          // 关掉开机启用
systemctl list-unit-files --state=enabled // 查看所有开机自启动服务
systemctl start system.service            // 启动服务    
systemctl stop system.service             // 关闭服务,关闭服务后,进程会全部被kill掉
systemctl status system.service           // 查看服务的状态
systemctl restart system.service          // 重启服务,先stop,再start
systemctl kill system.service             // 杀死一个服务的所有子进程
systemctl reload system.service           // 重新加载一个服务的配置文件
systemctl cat system.service              // 查看服务配置文件
systemctl reset-failed system.service     // 移除标记为丢失的Unit文件。在删除Unit文件后,由于缓存的关系,即使通过daemon-reload更新了缓存,在list-units中依然会显示标记为not-found的Unit
systemd-analyze                           // 系统启动单元模块花费时间
systemd-analyze blame                     // 系统启动每个单元花费时间
systemd-analyze critical-chain            // 系统启动花费最长时间单元
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值