How can I list all of the systemd targets?

If I want to list all of the possible systemd targets for a service I’m wanting to create, how can I do that?

Asked By: Evan Carroll

||

You can use

systemctl list-units --type target

Which will return something like,

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             >
Answered By: Evan Carroll

You may use:

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

  • list-unit-files: list unit files
  • --type target: show only target units
  • --all: list all unit files, regardless of their state

Also to list user targets:

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

Answered By: mlibre
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.