我们对service和chkconfig两个命令都不陌生,systemctl 是管制服务的主要工具, 它整合了chkconfig 与 service功能于一体。
systemctl is-enabled iptables.servicesystemctl is-enabled servicename.service #查询服务是否开机启动systemctl enable *.service #开机运行服务systemctl disable *.service #取消开机运行systemctl start *.service #启动服务systemctl stop *.service #停止服务systemctl restart *.service #重启服务systemctl reload *.service #重新加载服务配置文件systemctl status *.service #查询服务运行状态systemctl --failed #显示启动失败的服务
举例:ssh服务
查看状态:
systemctl status sshd.service
启动服务:
systemctl start sshd.service
重启服务: systemctl restart sshd.service开机自启: systemctl enable sshd.service