我們對service和chkconfig兩個指令都不陌生,systemctl 是管制服務的主要工具, 它整合了chkconfig 與 service功能于一體。
systemctl is-enabled iptables.service
systemctl 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 #顯示啟動失敗的服務
注:*代表某個服務的名字,如http的服務名為httpd
例如在CentOS 7 上安裝http
[root@CentOS7 ~]# yum -y install httpd
啟動服務(等同于service httpd start)
systemctl start httpd.service
停止服務(等同于service httpd stop)
systemctl stop httpd.service
重新開機服務(等同于service httpd restart)
systemctl restart httpd.service
檢視服務是否運作(等同于service httpd status)
systemctl status httpd.service
開機自啟動服務(等同于chkconfig httpd on)
systemctl enable httpd.service
開機時禁用服務(等同于chkconfig httpd on)
systemctl disable httpd.service
檢視服務是否開機啟動 (等同于chkconfig --list)
本文轉自 Mr_sheng 51CTO部落格,原文連結:http://blog.51cto.com/sf1314/1980567