Menu Close
14.2. 查看默认对象
默认目标单元由 /etc/systemd/system/default.target
文件代表。
流程
要确定默认使用哪个目标单元:
$ systemctl get-default graphical.target
使用符号链接决定默认对象:
$ ls -l /usr/lib/systemd/system/default.target
= 查看目标单元
默认情况下,systemctl list-units
命令只显示活跃的单位。
流程
列出所有载入的单元,而不考虑它们的状态:
$ systemctl list-units --type target --all
要列出所有当前载入的目标单元:
$ 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.target loaded active active Network paths.target loaded active active Paths remote-fs.target loaded active active Remote File Systems sockets.target loaded active active Sockets sound.target loaded active active Sound Card spice-vdagentd.target loaded active active Agent daemon for Spice guests 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. 17 loaded units listed.
14.2.1. 更改默认对象
默认目标单元由 /etc/systemd/system/default.target
文件代表。以下流程描述了如何使用 systemctl 命令更改默认目标:
流程
要确定默认目标单元:
# systemctl get-default
将系统配置为默认使用不同的目标单元:
# systemctl set-default multi-user.target rm /etc/systemd/system/default.target ln -s /usr/lib/systemd/system/multi-user.target /etc/systemd/system/default.target
这个命令将
/etc/systemd/system/default.target
文件替换为到/usr/lib/systemd/system/name.target
的符号链接,其中 name 是您要使用的目标单元的名称。使用您要默认使用的目标单元的名称替换 multi-user。表 14.3.
set-default
命令的通用目标Basic
涵盖基本引导的单元目标
rescue
拉取到基本系统的单元目标并生成救援 shell
多用户
设置多用户系统的单元目标
图形化
用于设置图形登录屏幕的单元目标
emergency
在主控制台中启动紧急 shell 的单元目标
sysinit
拉取系统初始化所需的服务的单元目标
重启
# reboot
其他资源
-
有关目标单元的详情请查看
systemd.special
manpage -
引导
man page