CentOS7 從查看、啟動、停止服務說起systemctl


執行命令“systemctl status 服務名.service”可查看服務的運行狀態,其中服務名后的.service 可以省略,這是CenOS7以后采用systemd作為初始化進程后產生的變化。

Systemctl是一個systemd工具,主要負責控制systemd系統和服務管理器。

Systemd是一個系統管理守護進程、工具和庫的集合,用於取代System V初始進程。Systemd的功能是用於集中管理和配置Linux系統。

以網絡服務network.service為例:

1、查看服務狀態

systemctl status network.service

2、控制服務

啟動服務
systemctl start network.service
重啟服務 systemctl restart network.service
停止服務 systemctl stop network.service

開機啟動服務
systemctl enable network.servic

停止開機啟動
systemctl disable network.servic

3、查找所有或者某個服務

systemctl list-units --type=service | grep network

4、Systemctl接受服務(.service),掛載點(.mount),套接口(.socket)和設備(.device)作為單元。

 列出所有可用單元
systemctl list-unit-files

列出所有運行中單元
systemctl list-units

列出所有失敗單元
systemctl --failed

5、使用systemctl命令殺死服務

systemctl kill network.service

6、列出所有系統掛載點

systemctl list-unit-files --type=mount

    UNIT FILE                     STATE   
    dev-hugepages.mount           static  
    dev-mqueue.mount              static  
    proc-sys-fs-binfmt_misc.mount static  
    sys-fs-fuse-connections.mount static  
    sys-kernel-config.mount       static  
    sys-kernel-debug.mount        static  
    tmp.mount                     disabled

 7、掛載、卸載、重新掛載、重載系統掛載點並檢查系統中掛載點狀態

systemctl start tmp.mount
systemctl stop tmp.mount
systemctl restart tmp.mount
systemctl reload tmp.mount
systemctl status tmp.mount

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM