Centos7使用 systemctl 操作系統層級 target

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

本文介紹如何使用 systemctl 切換不同的運作層級與設定預設層級。

列出可用的運作層級

$ 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'.

顯示目前系統預設運作層級

$ sudo systemctl get-default
graphical.target

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

$ sudo systemctl isolate multi-user.target

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

$ sudo systemctl isolate graphical.target

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

$ sudo systemctl set-default multi-user.target

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

$ sudo systemctl set-default graphical.target

你可能感兴趣的:(Centos7使用 systemctl 操作系統層級 target)