CentOS 7 中很多命令是跟 CentOS 6 是有区别的,就如 CentOS7 中已经没有 service 命令,而是启用了 systemctl 站群服务器命令.
systemctl 是系统服务管理器命令,实际上将 service 和检视 config 这两个命令组合到一起.
 
这里就服务管理相关命令进行介绍:下面以 “httpd” 服务为事例:
 
<1>启动/关闭/重启/重新载入服务
启动一个服务:systemctl start httpd.service
关闭一个服务:systemctl stop httpd.service
重启一个服务:systemctl restart httpd.service
重新载入服务:systemctl reload httpd.service
 
<2>检视服务状态
显示服务详细资讯:systemctl status httpd.service
仅显示是否 Active:systemctl is-active httpd.service
显示已启动的服务:systemctl list-units –type=service 或 ls /etc/systemd/system/*.wants
显示服务或任务的属性:systemctl show httpd.service
检查服务依赖关系:systemctl list-dependencies httpd.service
 
<3>开机启动/禁用服务
开机启动服务:systemctl enable httpd.service
开机禁用服务:systemctl disable httpd.service
检查服务是否开机启动及级别:systemctl is-enabled httpd.service