㈠ linux設置開機啟動程序linux正確的重啟和關閉方法
系統服務指的是那些常駐系統內存中的進程,主要用來提供一些基礎的系統和網路功能,例如資料庫、web伺服器、日誌等。
CentOS 7新增systemctl命令用來進行系統服務管理,取代了service和chkconfig,不過為了保持兼容性,在CentOS7中,仍然可以使用service和chkconfig命令。
以下示例適用於CentOS操作系統
查看當前已經啟動的服務
systemctl list-units查看所有服務
systemctl list-unit-files查看服務的狀態
以sshd服務為例,可以看到:
服務的當前狀態為:active (running)
是否開機啟動(enabled),
服務啟動腳本位於:/usr/lib/systemd/system/sshd.service
systemctl status sshd關閉、啟動、重啟服務
systemctl stop sshdsystemctl start sshdsystemctl restart sshd設置禁止開機啟動服務
systemctl disable sshd設置開機啟動服務
systemctl enable sshd重新載入服務配置文件
注意:後面無需任何選項
systemctl reload鎖定和解鎖服務
使用mask鎖定服務,鎖定後該服務將不能正常開啟
使用unmask解鎖服務
systemctl mask sshdsystemctl unmask sshd鎖定服務
解鎖服務