1. 程式人生 > 其它 >centos7新指令

centos7新指令

centos7保留了之前的service指令,但是該指令只能操作兩個服務,如下:

而centos7中就有了systemctl 這個新指令:

格式:systemctl start | stop | restart | status 服務名

在/usr/lib/systemd/system 目錄下存放著systemctl可以操作的所有服務

例如:

我們試著檢視防火牆的狀態:systemctl status firewalld

試著關閉防火牆:systemctl stop firewalld

但是關閉防火牆後,虛擬機器關機重啟後,防火牆會不會自動開啟,怎麼知道會不會呢?

使用sytemctl list-unit-files 檢視所有的指令是否會關機重啟,如果為enabled則會,為disabled則不會。

使用systemctl disabled firewalld.service把防火牆關機重啟關閉掉。

總結:

systemctl start | stop | restart | status 服務名 ----功能描述:對指定服務進行操作

systemctl list-unit-files ----功能描述:檢視服務開機啟動狀態

systemctl enable 服務名 ----功能描述:關掉指定服務的自動啟動

systemctl disable 服務名 ----功能描述:開啟指定服務的自動啟動