CentOS 7 的 systemctl 命令

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 is-enabled service_name

  7. 重启服务
    systemctl restart service_name

原文地址:https://www.cnblogs.com/1lin24/p/11648607.html