Centos-服务管理-systemctl

systemctl命令属于systemd软件包,这个软件包不仅可以完成系统的初始化工作,还能对系统和服务进行管理

在centos7中,服务单元取代启动脚本,服务单元以.service为文件扩展名,配置文件为 /etc/systemd,相当于Centos7版本前的service chkconfig命令组合

# namd.service 表示各服务的服务单元

服务管理

  1. 启动服务                  start

systemctl start named.service

  2. 停止服务                  stop

systemctl stop named.service

  3. 如果服务未运行则启动,服务运行则重启    restart

systemctl restart named.service

  4. 只有在服务运行态时候才能重启服务      try-start

systemctl try-start named.service

  5. 优雅重启,重新载入配置文件而不中断服务   reload

systemctl reload named.service

  6. 开机自启动                 enable

systemctl enable named.service

  7. 禁止开机自启动               disable

systemctl disable named.service

  8. 查看服务运行状态              status

systemctl status named.service

  9. 查看服务是否开机自启动           is-enabled

systemctl is-enabled named.service

  10. 查看服务开机自启动情况           list-unit-files --type=service

systemctl list-unit-files --type=service

  11. 查看各服务在不同的运行级别下自启动情况

ls /etc/systemd/system/*.wants/named.service

  12. 添加新的服务文件             daemon-reload

systemctl daemon-reload

电源管理

  1. 关闭系统                  poweroff

systemctl poweroff

  2. 重启系统                  reboot

systemctl reboot

  3. 待机模式                  suspend

systectl suspend

  4. 休眠模式                  hibemate

systemctl hibemate

  5. 混合休眠模式                hybrid-sleep

systemctl hybrid-sleep

  

原文地址:https://www.cnblogs.com/2bjiujiu/p/9043858.html