以前只要

service httpd start
/etc/init.d/httpd start
chkconfig --list
chkconfig httpd on

就可操作服務的生死

服務不再是由 init 負責,而是 systemd,而傳統的 runlevel 也改為 target

雖然說以上部份在 CentOS7 還是可以使用啦,只是要漸漸習慣使用 systemctl 才行

systemctl 已不把啟動檔放在 /etc/rc.d/init.d/ 裡面

改放在 /etc/systemd/system 裡,這裡也只放已被 enable ,它是從 /usr/lib/systemd/system/ 這裡 link 過來的

所以使用上一定有不習慣

啟動

systemctl start httpd

停止

systemctl stop httpd

開機啟用

systemctl enable httpd

開機停用

systemctl disable httpd

服務狀態

systemctl status httpd

列出全部服務

systemctl list-unit-files

列出服務,正在跑的

systemctl list-units --type service | grep running

顯示目前系統預設運作層級

systemctl get-default

如果顯示 multi-user.target,就以前的 runlevel 3

而 graphical.target 為 runlevel 5

切換運作層級至文字模式 runlevel 3

systemctl isolate multi-user.target

設定開機啟動至文字模式 runlevel 3

systemctl set-default multi-user.target

其它

systemctl restart httpd.service
systemctl reload httpd.service
systemctl kill httpd.service
systemctl show httpd.service

檢查服務是否在執行

systemctl is-active httpd.service

檢查服務是否被開機啟動

systemctl is-enabled httpd.service

 

Related posts 相關文章
升級 AlmaLinux 8.4 到 AlmaLinux 8.5
More...
將 CentOS 8 轉/遷移到 AlmaLinux 8
More...
將 CentOS 6 升級到 7,結論: 不升了
More...
Google 對於 Linux 的高效能調校實作
More...

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。