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 也可以省略
常用命令
-
查看服务状态
systemctl status service_name -
启动服务
systemctl start service_name -
关闭服务
systemctl stop service_name -
设置开机启动
systemctl enable service_name -
关闭开机启动
systemctl disable service_name -
查看服务是否设置开机启动
systemctl is-enabled service_name -
重启服务
systemctl restart service_name

浙公网安备 33010602011771号