以Ubuntu 18.04.2 LTS为例,列出Systemd启动target中涉及单元(Unit).
graphical.target
Requires=multi-user.target
Wants=display-manager.service
Conflicts=rescue.service rescue.target
After=multi-user.target rescue.service rescue.target display-manager.service
AllowIsolate=yes
# ls -l /etc/systemd/system/display-manager.service
lrwxrwxrwx 1 root root 32 6月 3 2019 /etc/systemd/system/display-manager.service -> /lib/systemd/system/gdm3.service
[Unit]
[email protected]
After=rc-local.service plymouth-start.service systemd-user-sessions.service
OnFailure=plymouth-quit.service
[Service]
ExecStartPre=/usr/share/gdm/generate-config
ExecStart=/usr/sbin/gdm3
# ls -l /lib/systemd/system/graphical.target.wants/
lrwxrwxrwx 1 root root 39 6月 3 2019 systemd-update-utmp-runlevel.service -> ../systemd-update-utmp-runlevel.service
[Unit]
Requisite=systemd-update-utmp.service
After=systemd-update-utmp.service
After=runlevel1.target runlevel2.target runlevel3.target runlevel4.target runlevel5.target
Before=shutdown.target
[Service]
ExecStart=/lib/systemd/systemd-update-utmp runlevel
# ls -l /etc/systemd/system/graphical.target.wants/
lrwxrwxrwx 1 root root 43 6月 3 2019 accounts-daemon.service -> /lib/systemd/system/accounts-daemon.service
lrwxrwxrwx 1 root root 35 6月 3 2019 udisks2.service -> /lib/systemd/system/udisks2.service
Multi-user.target
[Unit]
Description=Multi-User System
Documentation=man:systemd.special(7)
Requires=basic.target
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes
# ls -l /lib/systemd/system/multi-user.target.wants/
lrwxrwxrwx 1 root root 15 6月 3 2019 dbus.service -> ../dbus.service
lrwxrwxrwx 1 root root 15 6月 3 2019 getty.target -> ../getty.target
lrwxrwxrwx 1 root root 24 6月 3 2019 plymouth-quit.service -> ../plymouth-quit.service
lrwxrwxrwx 1 root root 29 6月 3 2019 plymouth-quit-wait.service -> ../plymouth-quit-wait.service
lrwxrwxrwx 1 root root 33 6月 3 2019 systemd-ask-password-wall.path -> ../systemd-ask-password-wall.path
lrwxrwxrwx 1 root root 25 6月 3 2019 systemd-logind.service -> ../systemd-logind.service
lrwxrwxrwx 1 root root 39 6月 3 2019 systemd-update-utmp-runlevel.service -> ../systemd-update-utmp-runlevel.service
lrwxrwxrwx 1 root root 32 6月 3 2019 systemd-user-sessions.service -> ../systemd-user-sessions.service
# ls -l /etc/systemd/system/multi-user.target.wants/
lrwxrwxrwx 1 root root 35 6月 3 2019 anacron.service -> /lib/systemd/system/anacron.service
lrwxrwxrwx 1 root root 40 6月 3 2019 avahi-daemon.service -> /lib/systemd/system/avahi-daemon.service
lrwxrwxrwx 1 root root 42 7月 31 2019 binfmt-support.service -> /lib/systemd/system/binfmt-support.service
lrwxrwxrwx 1 root root 41 6月 3 2019 console-setup.service -> /lib/systemd/system/console-setup.service
lrwxrwxrwx 1 root root 38 2月 5 2021 containerd.service -> /lib/systemd/system/containerd.service
lrwxrwxrwx 1 root root 32 6月 3 2019 cron.service -> /lib/systemd/system/cron.service
lrwxrwxrwx 1 root root 40 6月 3 2019 cups-browsed.service -> /lib/systemd/system/cups-browsed.service
lrwxrwxrwx 1 root root 29 6月 3 2019 cups.path -> /lib/systemd/system/cups.path
lrwxrwxrwx 1 root root 37 6月 3 2019 dns-clean.service -> /lib/systemd/system/dns-clean.service
lrwxrwxrwx 1 root root 38 6月 3 2019 irqbalance.service -> /lib/systemd/system/irqbalance.service
lrwxrwxrwx 1 root root 38 6月 3 2019 kerneloops.service -> /lib/systemd/system/kerneloops.service
lrwxrwxrwx 1 root root 40 6月 3 2019 ModemManager.service -> /lib/systemd/system/ModemManager.service
lrwxrwxrwx 1 root root 47 6月 3 2019 networkd-dispatcher.service -> /lib/systemd/system/networkd-dispatcher.service
lrwxrwxrwx 1 root root 38 6月 3 2019 networking.service -> /lib/systemd/system/networking.service
lrwxrwxrwx 1 root root 42 6月 3 2019 NetworkManager.service -> /lib/systemd/system/NetworkManager.service
lrwxrwxrwx 1 root root 36 6月 3 2019 ondemand.service -> /lib/systemd/system/ondemand.service
lrwxrwxrwx 1 root root 36 6月 3 2019 pppd-dns.service -> /lib/systemd/system/pppd-dns.service
lrwxrwxrwx 1 root root 36 6月 3 2019 remote-fs.target -> /lib/systemd/system/remote-fs.target
lrwxrwxrwx 1 root root 33 6月 3 2019 rsync.service -> /lib/systemd/system/rsync.service
lrwxrwxrwx 1 root root 35 6月 3 2019 rsyslog.service -> /lib/systemd/system/rsyslog.service
......
lrwxrwxrwx 1 root root 31 2月 5 2021 ssh.service -> /lib/systemd/system/ssh.service
lrwxrwxrwx 1 root root 44 6月 3 2019 systemd-resolved.service -> /lib/systemd/system/systemd-resolved.service
lrwxrwxrwx 1 root root 36 6月 3 2019 thermald.service -> /lib/systemd/system/thermald.service
lrwxrwxrwx 1 root root 38 2月 5 2021 ubuntu-fan.service -> /lib/systemd/system/ubuntu-fan.service
lrwxrwxrwx 1 root root 31 6月 3 2019 ufw.service -> /lib/systemd/system/ufw.service
lrwxrwxrwx 1 root root 47 6月 3 2019 unattended-upgrades.service -> /lib/systemd/system/unattended-upgrades.service
lrwxrwxrwx 1 root root 42 6月 3 2019 wpa_supplicant.service -> /lib/systemd/system/wpa_supplicant.service
basic.target
[Unit]
Description=Basic System
Documentation=man:systemd.special(7)
Requires=sysinit.target
Wants=sockets.target timers.target paths.target slices.target
After=sysinit.target sockets.target paths.target slices.target tmp.mount
RequiresMountsFor=/var /var/tmp
Wants=tmp.mount
# ls -l /lib/systemd/system/sockets.target
-rw-r--r-- 1 root root 396 1月 28 2018 /lib/systemd/system/sockets.target
# ls -l /lib/systemd/system/sockets.target.wants
lrwxrwxrwx 1 root root 14 6月 3 2019 dbus.socket -> ../dbus.socket
lrwxrwxrwx 1 root root 25 6月 3 2019 systemd-initctl.socket -> ../systemd-initctl.socket
lrwxrwxrwx 1 root root 32 6月 3 2019 systemd-journald-audit.socket -> ../systemd-journald-audit.socket
lrwxrwxrwx 1 root root 34 6月 3 2019 systemd-journald-dev-log.socket -> ../systemd-journald-dev-log.socket
lrwxrwxrwx 1 root root 26 6月 3 2019 systemd-journald.socket -> ../systemd-journald.socket
lrwxrwxrwx 1 root root 31 6月 3 2019 systemd-udevd-control.socket -> ../systemd-udevd-control.socket
lrwxrwxrwx 1 root root 30 6月 3 2019 systemd-udevd-kernel.socket -> ../systemd-udevd-kernel.socket
# ls -l /etc/systemd/system/sockets.target.wants/
lrwxrwxrwx 1 root root 32 6月 3 2019 acpid.socket -> /lib/systemd/system/acpid.socket
lrwxrwxrwx 1 root root 41 6月 3 2019 apport-forward.socket -> /lib/systemd/system/apport-forward.socket
lrwxrwxrwx 1 root root 39 6月 3 2019 avahi-daemon.socket -> /lib/systemd/system/avahi-daemon.socket
lrwxrwxrwx 1 root root 31 6月 3 2019 cups.socket -> /lib/systemd/system/cups.socket
lrwxrwxrwx 1 root root 33 2月 5 2021 docker.socket -> /lib/systemd/system/docker.socket
lrwxrwxrwx 1 root root 32 6月 3 2019 snapd.socket -> /lib/systemd/system/snapd.socket
lrwxrwxrwx 1 root root 32 6月 3 2019 uuidd.socket -> /lib/systemd/system/uuidd.socket
# ls -l /lib/systemd/system/timers.target
-rw-r--r-- 1 root root 445 1月 28 2018 /lib/systemd/system/timers.target
# ls -l /lib/systemd/system/timers.target.wants
lrwxrwxrwx 1 root root 31 6月 3 2019 systemd-tmpfiles-clean.timer -> ../systemd-tmpfiles-clean.timer
# ls -l /etc/systemd/system/timers.target.wants/
lrwxrwxrwx 1 root root 33 6月 3 2019 anacron.timer -> /lib/systemd/system/anacron.timer
lrwxrwxrwx 1 root root 35 6月 3 2019 apt-daily.timer -> /lib/systemd/system/apt-daily.timer
lrwxrwxrwx 1 root root 43 6月 3 2019 apt-daily-upgrade.timer -> /lib/systemd/system/apt-daily-upgrade.timer
lrwxrwxrwx 1 root root 32 6月 3 2019 fstrim.timer -> /lib/systemd/system/fstrim.timer
lrwxrwxrwx 1 root root 35 6月 3 2019 motd-news.timer -> /lib/systemd/system/motd-news.timer
lrwxrwxrwx 1 root root 43 6月 3 2019 snapd.snap-repair.timer -> /lib/systemd/system/snapd.snap-repair.timer
# ls -l /lib/systemd/system/paths.target
-rw-r--r-- 1 root root 394 1月 28 2018 /lib/systemd/system/paths.target
# ls -l /etc/systemd/system/paths.target.wants/
lrwxrwxrwx 1 root root 30 6月 3 2019 acpid.path -> /lib/systemd/system/acpid.path
lrwxrwxrwx 1 root root 42 6月 3 2019 apport-autoreport.path -> /lib/systemd/system/apport-autoreport.path
# ls -l /lib/systemd/system/slices.target
-rw-r--r-- 1 root root 449 1月 28 2018 /lib/systemd/system/slices.target
sysinit.target
[Unit]
Description=System Initialization
Documentation=man:systemd.special(7)
Conflicts=emergency.service emergency.target
Wants=local-fs.target swap.target
After=local-fs.target swap.target emergency.service emergency.target
# ls -l /lib/systemd/system/local-fs.target
-rw-r--r-- 1 root root 547 1月 28 2018 /lib/systemd/system/local-fs.target
# ls -l /lib/systemd/system/local-fs.target.wants/
lrwxrwxrwx 1 root root 29 6月 3 2019 systemd-remount-fs.service -> ../systemd-remount-fs.service
# ls -l /lib/systemd/system/swap.target
-rw-r--r-- 1 root root 393 1月 28 2018 /lib/systemd/system/swap.target
local-fs.target
Conflicts=shutdown.target
After=local-fs-pre.target
OnFailure=emergency.target
OnFailureJobMode=replace-irreversibly
# ls /lib/systemd/system/local-fs.target.wants/
lrwxrwxrwx 1 root root 29 6月 3 2019 systemd-remount-fs.service -> ../systemd-remount-fs.service
systemd-remount-fs.service
After=systemd-fsck-root.service
Before=local-fs-pre.target local-fs.target shutdown.target
Wants=local-fs-pre.target
ConditionPathExists=/etc/fstab
ExecStart=/lib/systemd/systemd-remount-fs
systemd-fsck-root.service
Wants=systemd-fsckd.socket
Before=local-fs.target shutdown.target
After=systemd-fsckd.socket
ExecStart=/lib/systemd/systemd-fsck