最近升版到centos7發現服務的啟動方式不太一樣,這邊是網路上搜尋到的相關資料

service XXXX(服務名稱) start (stop, restart...)

或是

/etc/init.d/XXXX(服務名稱) start (stop, restart...)

但是現在在 /etc/init.d/ 目錄底下看不到幾個服務名稱了,

C7已經徹底改變了許多傳統的作法。

所以把這個重要指令的說明列出來做為參考:

啟動服務 (service):

systemctl start vsftpd (範例,其他如httpd, named, mysql...等服務皆同)

停止服務:

systemctl stop vsftpd

重新啟動服務:

systemctl restart vsftpd

開機後隨系統啟動服務:

systemctl enable vsftpd

開機後不隨系統啟動服務:

systemctl disable vsftpd

顯示服務狀態:

systemctl status vsftpd
systemctl is-active vsftpd

列出 vsftpd FTP Server 啟動狀態:

systemctl list-unit-files | grep vsftpd

vsftpd.service                              disabled
[email protected]                           disabled
vsftpd.target                                disabled

檢查是否有設定成功

systemctl list-unit-files | grep vsftpd

vsftpd.service                              enabled
[email protected]                             disabled
vsftpd.target                               disabled

新舊指令比較

任務 舊指令 新指令
使某服務自動啟動 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

 

參考資料

頭城國小資訊組

http://blog.ilc.edu.tw/blog/blog/25793/post/78462/511719

By tony

自由軟體愛好者~喜歡不斷的思考各種問題,有新的事物都會想去學習嘗試 做實驗並熱衷研究 沒有所謂頂天的技術 只有謙虛及不斷的學習 精進專業,本站主要以分享系統及網路相關知識、資源而建立。 Github http://stnet253.github.io

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料