Chapter 8. Controlling Services and Daemons.
- Introduction to systemd
System startup and server processes are managed by the systemd System and Service Manager.
Daemons are processes that wait or run in the background performing various tasks.
To listen for connections, a daemon uses a socket.
A service often refers to one or more daemons, but starting or stopping a service may instead make a one-time change to the state of the system.
In Red Hat Enterprise Linux 7, process ID 1 is systemd, the new init system.
The status of a service can be viewed with systemctl status name.type.
- Listing unit files with systemctl
# systemctl
查詢系統啟動時,所有 units 的狀態
# systemctl --type=service
只查詢 unit type 為 service 的 unit 狀態
# systemctl status unit -l
可使用 -l 參數以顯示較完整的狀態
# systemctl is-active unit
查詢該 unit 是否正在運作中
# systemctl is-enabled unit
開機時有沒有預設要啟用這個 unit
# systemctl [command] [--type=TYPE] [--all]
list-units :列出目前有啟動的 unit,若加上 --all 才會列出沒啟動的
list-unit-files :將所有檔案列表說明
TYPE :unit type,主要有 service, socket, target 等
# systemctl --failed --type=service
只查詢 unit type 為 service 且狀態為 failed 的 unit
- Summary of systemctl commands