1

In a nutshell, why systemctl list-units doesn't list poweroff.target or reboot.target and systemctl list-unit-files does? The .target files are in /lib/systemd/system folder; systemctl cat poweroff.target and systemctl cat reboot.target shows the unit content. systemd.special(7) describes them and states those are special units. So, what is the difference, let's say, between poweroff.target and multi-user.target that one shows up in list-units command and the other doesn't?

2

In a nutshell, because they’re inactive and/or disabled.

systemctl list-units only lists active units by default. When the system is running, the poweroff and reboot targets aren’t active, so they’re not listed. You can add -a to see all enabled units, which will add some special targets (but not necessarily all; on my system, poweroff is disabled).

systemctl list-unit-files lists all installed units in the file system, regardless of their status. This means it lists disabled units too (but not generated units).

(Both commands describe this briefly in the footers they output.)

  • I forgot to mention that I had tried systemctl list-units -a and poweroff.target and reboot.target didn't show up either. So, the reason is they are disabled, huh? That means there are unit files for them but they were not "installed" using systemctl enable <unit>, right? Thanks – Adriano_epifas Mar 19 at 5:37
  • list-unit-files will show their status, but yes, if they’re not listed with list-units -a, they’re not enabled. – Stephen Kitt Mar 19 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.