Centos7使用 systemctl 操作系統(tǒng)層級 target

在 RHEL/CentOS 7 之前,系統(tǒng)啟動是經(jīng)由 init 所負(fù)責(zé),從 RHEL/CentOS 7 開始已改用 systemd 處理系統(tǒng)運作階層(Run Level),而傳統(tǒng) runlevel 已改為 target 表示。

本文介紹如何使用 systemctl 切換不同的運作層級與設(shè)定預(yù)設(shè)層級。

列出可用的運作層級

$ sudo systemctl list-units --type target
[sudo] password for $USER:
UNIT                LOAD   ACTIVE SUB    DESCRIPTION
basic.target        loaded active active Basic System
cryptsetup.target   loaded active active Local Encrypted Volumes
getty.target        loaded active active Login Prompts
graphical.target    loaded active active Graphical Interface
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target     loaded active active Local File Systems
multi-user.target   loaded active active Multi-User System
network.target      loaded active active Network
paths.target        loaded active active Paths
remote-fs.target    loaded active active Remote File Systems
slices.target       loaded active active Slices
sockets.target      loaded active active Sockets
swap.target         loaded active active Swap
sysinit.target      loaded active active System Initialization
timers.target       loaded active active Timers

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

15 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

顯示目前系統(tǒng)預(yù)設(shè)運作層級

$ sudo systemctl get-default
graphical.target

切換運作層級至文字模式(runlevel 3)

$ sudo systemctl isolate multi-user.target

切換運作層級至 GUI 模式(runlevel 5)

$ sudo systemctl isolate graphical.target

設(shè)定開機啟動至文字模式(runlevel 3)

$ sudo systemctl set-default multi-user.target

設(shè)定開機啟動至 GUI 模式(runlevel 5)

$ sudo systemctl set-default graphical.target
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容