有人能告诉我 Ubuntu 18.04 上的默认运行级别信息存储在哪里吗(我看不到 /etc/inittab 文件了)。谢谢!
答案1
在当前的 Ubuntu 版本中systemd用作 init 系统。
它使用“目标”术语表示运行级别。
Ubuntu 有几个目标:
$ systemctl list-units --type=target --all | cat
UNIT LOAD ACTIVE SUB DESCRIPTION
● all.target not-found inactive dead all.target
basic.target loaded active active Basic System
cryptsetup.target loaded active active Local Encrypted Volumes
emergency.target loaded inactive dead Emergency Mode
getty-pre.target loaded inactive dead Login Prompts (Pre)
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-online.target loaded active active Network is Online
network-pre.target loaded inactive dead Network (Pre)
network.target loaded active active Network
nss-lookup.target loaded active active Host and Network Name Lookups
nss-user-lookup.target loaded active active User and Group Name Lookups
paths.target loaded active active Paths
remote-fs-pre.target loaded inactive dead Remote File Systems (Pre)
remote-fs.target loaded active active Remote File Systems
rescue.target loaded inactive dead Rescue Mode
shutdown.target loaded inactive dead Shutdown
slices.target loaded active active Slices
sockets.target loaded active active Sockets
sound.target loaded active active Sound Card
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
● syslog.target not-found inactive dead syslog.target
time-sync.target loaded active active System Time Synchronized
timers.target loaded active active Timers
umount.target loaded inactive dead Unmount All Filesystems
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.
29 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
对于桌面系统,默认值为graphical.target
:
$ systemctl get-default
graphical.target
你可以随时使用命令切换目标systemctl isolate
。下面的示例将切换到基于文本的multi-user.target
:
sudo systemctl isolate multi-user.target
有关详细信息,请参阅Ubuntu 官方文档和RedHat 官方文档。
答案2
可以通过以下方式更改默认目标:
sudo systemctl set-default multi-user.target
此示例将运行级别 3 设置为默认值。