CentOS 的 服务管理,systemctl 的花式命令大全
一、使用systemctl管理服务
在 centos7中, 可以使用systemctl显示,启动,停止和重启指定服务,操作简单易用。 它整合了chkconfig与service功能于一体。 原服务都安装在 /usr/lib/systemd/system/
1.1 命名格式
systemctl cmd service_name.service
其中:
* cmd 指命令名称
* service_name 指的是服务名称
* .service 也可以省略
1.2 常用指令
#启动服务
systemctl start firewalld
#停止服务
systemctl stop firewalld
#重启服务
systemctl restart firewalld
#仅仅当服务正在运行时才重启
systemctl try-restart firewalld
#重新加载服务
systemctl reload firewalld
#开机运行服务
systemctl enable firewalld
#取消开机运行服务
systemctl disable firewalld
1.3 状态查询命令
#查询服务运行状态
systemctl status firewalld
#查看服务是否在运行
systemctl is-active firewalld
#查询服务是否开机启动
systemctl is-enabled firewalld
#显示当前已经运行的所有服务
systemctl [list-units] --type service
systemctl [list-units] -at service
#显示所有服务
systemctl [list-units] --type --all
systemctl [list-units] -at service
#显示已加载但出于failed状态的服务
systemctl [list-units] --type service -failed
systemctl [list-units] -t service --failed
引用链接