1、service是一個腳本命令,分析service可知是去/etc/init.d目錄下執行相關程序。service和chkconfig結合使用。
服務配置文件存放目錄/etc/init.d/
2、systemd
centos7版本中使用了systemd,systemd同時兼容service,對應的命令就是systemctl
systemctl命令是系統服務管理器指令,它實際上將 service 和 chkconfig 這兩個命令組合到一起。
任務 舊指令 新指令
使某服務自動啟動 chkconfig --level 3 httpd on systemctl enable httpd.service
使某服務不自動啟動 chkconfig --level 3 httpd off systemctl disable httpd.service
檢查服務狀態 service httpd status systemctl status httpd.service
(服務詳細信息) systemctl is-active httpd.service (僅顯示是否 Active)
顯示所有已啟動的服務 chkconfig --list systemctl list-units --type=service
啟動某服務 service httpd start systemctl start httpd.service
停止某服務 service httpd stop systemctl stop httpd.service
重啟某服務 service httpd restart systemctl restart httpd.service