如何列出所有 systemd 目标?

如何列出所有 systemd 目标?

如果我想列出我想要创建的服务的所有可能的 systemd 目标,我该怎么做?

答案1

您可以使用

systemctl list-units --type target

这会返回类似的东西,

UNIT                                       LOAD   ACTIVE SUB    DESCRIPTION        >
basic.target                               loaded active active Basic System       >
blockdev@dev-mapper-nvme0n1p3_crypt.target loaded active active Block Device Prepar>
bluetooth.target                           loaded active active Bluetooth          >
cryptsetup.target                          loaded active active Local Encrypted Vol>
getty.target                               loaded active active Login Prompts      >
graphical.target                           loaded active active Graphical Interface>
local-fs-pre.target                        loaded active active Local File Systems >
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            >
nfs-client.target                          loaded active active NFS client services>
paths.target                               loaded active active Paths              >
remote-fs-pre.target                       loaded active active Remote File Systems>
remote-fs.target                           loaded active active Remote File Systems>
rpcbind.target                             loaded active active RPC Port Mapper    >
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 Initializati>
time-set.target                            loaded active active System Time Set    >
time-sync.target                           loaded active active System Time Synchro>
timers.target                              loaded active active Timers             >

答案2

您可以使用:

systemctl list-unit-files --type target --all

  • list-unit-files:列出单元文件
  • --type target:仅显示目标单位
  • --all:列出所有单元文件,无论其状态如何

还要列出用户目标:

systemctl list-unit-files --type target --all --user

相关内容