Linux 服務管理

2022-01-28 22:39:48 字數 1150 閱讀 5988

linux裡面的第乙個程序,是整個系統的父程序。

在rhel6版本之前,包括rhel6,採用的第乙個程序叫做init。通過init程序啟動的後續程序都是序列啟動的。

在rhel7版本,採用第乙個程序叫做systemd。該程序相比於init來說,採用並行方式啟動後續程序。

systemd管理的內容不僅僅有service,systemd管理的單位是unit,service只是unit中的一種。

systemctl status sshd.service     # 檢視服務的狀態

systemctl stop sshd.service # 停止服務

systemctl start sshd.service # 啟動服務

systemctl restart sshd.service # 重啟服務

systemctl enable sshd.service # 設值服務開機自啟

systemctl disable sshd.service # 設值服務開機不自啟

systemctl mask sshd.service # 鎖定改服務,這個時候start和restart等操作無效

systemctl unmask sshd.service # 解除該服務的鎖定

systemctl is-enabled sshd.service # 檢視當前服務是否為開機自啟

systemctl is-active sshd.service # 檢視當前服務是否處於活躍狀態

target是由服務組成的一類啟動目標,systemd可以設定啟動目標,如果systemd指定了乙個target作為啟動目錄,那麼下次系統啟動的時候就會啟動target裡面的所有服務。

systemctl isolate multi-user.target # 臨時切換到字元介面

systemctl isolate graphical.target # 臨時切換到圖形介面

systemctl get-default # 檢視下次開機啟動載入哪個target

systemctl set-default multi-user.target # 修改下次開機啟動的target

Linux 服務管理

命令形式 systemctl options.unit commands start 啟動服務 stop 停止服務 restart 重啟服務 status 檢視服務狀態 unit file commands enable 開機自啟 disable 開機時服務關閉 seclinux 檢視狀態 gete...

Linux 服務管理

原始碼包安裝服務 2.1.1.0 啟動 2.1.1.1 自啟動 chkconfig level 執行級別 如 2345 服務名 on 修改 etc rc.d rc.local 開啟在輸入密碼前會執行此檔案裡面的,直接在裡面寫服務啟動命令 使用ntsysv命令,使用介面來設定 可以管理xinetd 2...

Linux服務管理

介紹 服務 service 本質就是程序,但是是執行在後台,通常都會監聽某個埠,等待其他程式的請求,比如 mysql,sshd,防火牆等 因此我們又稱為守護程序,是linux中非常重要的知識點。基本語法 service 服務名 引數 常用引數 start 開啟 stop 關閉 restart 重啟 ...