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