CentOS 7 ------systemctl 的用法

我們對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)

更多CentOS相關信息見CentOS 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=14

本文永久更新鏈接地址http://www.linuxidc.com/Linux/2014-11/109236.htm

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章