众所周知debian9和debian8已经用systemd的targets代替了原有的/etc/inittab文件,用户已无法通过更改/etc/inittab来实现更改默认运行级。修改默认桌面可通过使用systemctl命令或创建一个运行级targets文件的软链接的方式来实现。
首先需切换到root用户下。
su -
方法一:(通过命令来切换)
1.查看当前的运行级
# systemctl get-default
graphical.target
2.查看可供替换的运行级
# systemctl list-units --type=target
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
cryptsetup.target loaded active active 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-online.target loaded active active Network is Online
network.target loaded active active Network
nss-user-lookup.target loaded active active User and Group Name Lookups
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
sound.target loaded active active Sound Card
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
time-sync.target loaded active active System Time Synchronized
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.
3.替换默认运行级
# systemctl set-default multi-user.target (替换为多用户文本)
方法二(创建软链接来替换)
# ln -sf /lib/systemd/system/runlevel5.target /lib/systemd/system/default.target
转载于:https://blog.51cto.com/10973437/2071817