1. 程式人生 > >一天一個命令之-systemctl

一天一個命令之-systemctl

systemd 是 Linux 下的一款系統和服務管理器,相容 SysV 和 LSB 的啟動指令碼。systemd 的特性有:支援並行化任務;同時採用 socket 式與 D-Bus 匯流排式啟用服務;按需啟動守護程序(daemon);利用 Linux 的 cgroups 監視程序;支援快照和系統恢復;維護掛載點和自動掛載點;各服務間基於依賴關係進行精密控制。

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