CentOS7 服務的啟動與停止 -- systemctl - Rafael Lab

Breaking

BANNER 728X90

2018年9月10日 星期一

CentOS7 服務的啟動與停止 -- systemctl

一、過去: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

 (一)Http 服務

  •  啟動 systemctl start httpd 
  •  停止 systemctl stop httpd
  •  重新啟動 systemctl restart httpd
  •  開機啟用 systemctl enable httpd 
  •  開機停用 systemctl disable httpd 
  •  服務狀態 systemctl status httpd

  • 重新整理 systemctl reload httpd.service 
  • 強制停止 systemctl kill httpd.service 
  • 顯示服務資訊 systemctl show httpd.service

 (二)開機服務設定

  • 列出全部服務 systemctl list-unit-files 
  • 列出執行中服務 systemctl list-units --type service | grep running 
  • 顯示目前系統預設運作層級 systemctl get-default 
  • 切換至文字模式 multi-user.target (以前的 runlevel 3 ) systemctl isolate multi-user.target 
  • 切換至圖形模式 graphical.target (以前的 runlevel 5 )  systemctl isolate graphical.target 
  • 設定開機啟動至文字模式 (以前的 runlevel 3 ) systemctl set-default multi-user.target 


沒有留言:

張貼留言