Linux – systemctl管理服務(wù)
一、通過(guò)systemctl管理單一服務(wù)(service unit)
systemctl [command] [unit]
command:
start : 立刻啟動(dòng)后面跟的unit
stop : 立刻關(guān)閉后面接的unit
restart : 立刻重啟后面的unit
reload : 不關(guān)閉后面的unit的情況下,重新加載配置文件,讓設(shè)置生效
enable : 設(shè)置下次開(kāi)機(jī)后,后面接的unit會(huì)被自動(dòng)啟動(dòng)
disable : 設(shè)置下次開(kāi)機(jī)后,后面接的unit不會(huì)被自動(dòng)啟動(dòng)
status : 目前后面接的這個(gè)unit的狀態(tài)(設(shè)置),有沒(méi)有正在執(zhí)行,會(huì)不會(huì)開(kāi)機(jī)啟動(dòng)等等
is-active : 目前有沒(méi)有正在運(yùn)行中
is-enable : 開(kāi)機(jī)時(shí)有沒(méi)有默認(rèn)啟動(dòng)這個(gè)unit
二、通過(guò)systemctl查看系統(tǒng)上所有的服務(wù)
systemctl [command] [--type=TYPE] [--all]
command:
list-units:依據(jù)unit顯示目前有啟動(dòng)的unit,若加上all就會(huì)也列出沒(méi)啟動(dòng)的,如果沒(méi)加command默認(rèn)就是這個(gè)
list-unit-files:根據(jù)/usr/lib/systemd/system/內(nèi)的文件,將所有文件列表說(shuō)明
systemctl : 列出系統(tǒng)上所有啟動(dòng)的unit
systemctl list-unit-files : 列出所有已安裝的unit
systemctl list-units --type=service --all : 列出所有service類別的deamon,并且啟沒(méi)啟動(dòng)都列出來(lái)
三、通過(guò)systemctl管理不同的操作環(huán)境(target unit)
systemctl list-units --type=target --all
systemctl [command] [unit.target]
command:
get-default : 取得目前的target
set-default : 設(shè)置后面接的tarhet成為默認(rèn)的操作模式
isolate : 切換到后面接的模式
systemd也提供了幾個(gè)簡(jiǎn)單的命令給我們切換模式:
systemctl poweroff 關(guān)機(jī)
systemctl reboot 重新開(kāi)機(jī)
systemctl suspend 進(jìn)入掛起模式
systemctl hibernate 進(jìn)入休眠模式
systemctl rescue 強(qiáng)制進(jìn)入恢復(fù)模式
systemctl emergency 強(qiáng)制進(jìn)入緊急恢復(fù)模式
四、通過(guò)systemctl分析各服務(wù)之間的依賴性
systemctl list-dependencies [unit] [--reverse]
--reverse : 反向追蹤哪個(gè)使用了這個(gè)unit
在看看誰(shuí)會(huì)用到multi-user.target呢?文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-610787.html
總結(jié)
本節(jié)主要介紹了關(guān)于systemctl
管理的一些相關(guān)操作,唐怡佳繼續(xù)加油叭!!!
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-610787.html
到了這里,關(guān)于【Linux -- systemctl管理服務(wù)】的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!