fedora-system-default-target

了解fedora default.target


更新記錄

item note
20160707 第一版

目錄


systemd

  • /etc/systemd/system/graphical.target.wants/:使用者設定載入的 unit
  • /usr/lib/systemd/system/graphical.target.wants/:系統預設載入的 unit

pstree

systemd為第一個process

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@localhost /]# pstree
systemd─┬─NetworkManager─┬─{gdbus}
│ └─{gmain}
├─abrt-dump-journ
├─abrt-watch-log
├─abrtd───{gdbus}
├─accounts-daemon─┬─{gdbus}
│ └─{gmain}
├─alsactl
├─2*[at-spi-bus-laun─┬─dbus-daemon]
│ ├─{gdbus}]
│ └─{gmain}]
├─2*[at-spi2-registr───{gdbus}]
├─atd

default.target

1
2
3
4
5
6
7
8
[root@localhost /]# ls -l /usr/lib/systemd/system/runlevel*.target
lrwxrwxrwx. 1 root root 15 Jan 7 18:07 /usr/lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 Jan 7 18:07 /usr/lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 17 Jan 7 18:07 /usr/lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Jan 7 18:07 /usr/lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Jan 7 18:07 /usr/lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 Jan 7 18:07 /usr/lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 Jan 7 18:07 /usr/lib/systemd/system/runlevel6.target -> reboot.target

systemctl set-default xx

列出可用的運作層級

systemctl list-units –type target

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@localhost system]# 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
nfs-client.target loaded active active NFS client services
nss-user-lookup.target loaded active active User and Group Name Lookups
paths.target loaded active active Paths
remote-fs-pre.target loaded active active Remote File Systems (Pre)
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
timers.target loaded active active Timers

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

systemctl get-default

1
2
[root@localhost system]# systemctl get-default
graphical.target

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

systemctl set-default multi-user.target

1
2
3
4
5
[root@localhost system]# systemctl set-default multi-user.target 
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
[root@localhost system]# systemctl get-default
multi-user.target
1
2
[root@localhost system]# ls -l /etc/systemd/system/default.target 
lrwxrwxrwx 1 root root 41 Jul 7 16:02 /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target

參考來源