CentOS 7 中很多命令是跟 CentOS 6 是有區別的,就如 CentOS7 中已經沒有 service 命令,而是啟用了 systemctl 站群服務器命令.
systemctl 是系統服務管理器命令,實際上將 service 和檢視 config 這兩個命令組合到一起.
 
這裡就服務管理相關命令進行介紹:下面以 “httpd” 服務為事例:
 
<1>啟動/關閉/重啟/重新載入服務
啟動一個服務:systemctl start httpd.service
關閉一個服務:systemctl stop httpd.service
重啟一個服務:systemctl restart httpd.service
重新載入服務:systemctl reload httpd.service
 
<2>檢視服務狀態
顯示服務詳細資訊:systemctl status httpd.service
僅顯示是否 Active:systemctl is-active httpd.service
顯示已啟動的服務:systemctl list-units –type=service 或 ls /etc/systemd/system/*.wants
顯示服務或任務的屬性:systemctl show httpd.service
檢查服務依賴關係:systemctl list-dependencies httpd.service
 
<3>開機啟動/禁用服務
開機啟動服務:systemctl enable httpd.service
開機禁用服務:systemctl disable httpd.service
檢查服務是否開機啟動及級別:systemctl is-enabled httpd.service