Centos 7.* 的 systemctl 命令

那年仲夏 提交于 2019-12-01 02:42:05

Centos 7.* 使用 Systemd 进行系统初始化,因此,Centos 7.* 中我们可以使用 systemctl 管理系统中的服务。

systemctl 管理的服务均包含了一个以 .service 结尾的文件,存放于 /lib/systemd/

(在 Centos 7.* 中,使用 yum install 命令安装的软件都会在 /linb/systemd/ 下自动创建对应的 .service 文件。)

命令格式

systemctl cmd service_name.service

其中:

  • cmd 指命令名称
  • service_name 指的是服务名称
  • .service 也可以省略

常用命令

  1. 查看服务状态
    systemctl status service_name

  2. 启动服务
    systemctl start service_name

  3. 关闭服务
    systemctl stop service_name

  4. 设置开机启动
    systemctl enable service_name

  5. 关闭开机启动
    systemctl disable service_name

  6. 重启服务
    systemctl restart service_name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!