systemctl命令

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

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

在Linux生態系統中,Systemd被部署到了大多數的標準Linux發行版中,只有爲數很少的幾個發行版還沒有部署。Systemd一般是全部其它守護進程的父進程,但並不是老是如此。spa

服務所在位置: /usr/lib/systemd/system/hibernate

新舊指令比較:rest

任務 舊指令 新指令
使某服務自動啓動 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-enabled 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
某服務從新加載配置文件 service httpd reload systemctl reload httpd.service

 

例子:進程

# systemctl   #輸出已激活單元
# systemctl list-units    #輸出已激活單元
# systemctl --failed    #輸出運行失敗的單元
# systemctl list-unit-files   #查看全部已安裝服務
# systemctl start nginx    #啓動nginx
# systemctl stop nginx    #中止nginx
# systemctl restart nginx   #重啓nginx
# systemctl reload nginx    #從新加載nginx配置
# systemctl status nginx    #輸出nginx運行狀態
# systemctl is-enabled nginx   #檢查nginx是否配置爲自動啓動
# systemctl enable nginx    #開機自動啓動nginx
# systemctl disable nginx    #取消開機自動啓動nginx
# systemctl help nginx    #顯示nginx的手冊頁
# systemctl daemon-reload    #從新載入systemd,掃描新的或有變更的單元
# systemctl reboot    #重啓
# systemctl poweroff    #退出系統並中止電源
# systemctl suspend    #待機
# systemctl hibernate   #休眠
# systemctl hybrid-sleep    #混合休眠模式(同時休眠到硬盤並待機
# systemctl isolate graphical.target   #等價於telinit 3 或 telinit 5ci

相關文章
相關標籤/搜索