This question asks: "How to list all enabled services from systemctl?" Answers on that page include:

systemctl list-unit-files | grep enabled
systemctl list-unit-files --state=enabled

At least as of systemd version 229 (on Ubuntu 16.04), systemctl list-unit-files will not include "LSB" services that are launched via legacy init scripts.

Therefore, the original question seems to remain unanswered: Can systemd display a list of ALL the services (and other unit types) that it will try to start at boot, including legacy services?


$ systemctl list-units | grep LSB | grep grub
  grub-common.service    loaded    active exited    LSB: Record successful boot for GRUB

$ systemctl list-unit-files | grep enabled | grep grub || echo 'nothing found'
nothing found

$ systemctl is-enabled grub-common
grub-common.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install is-enabled grub-common

systemctl knows about grub-common, and if you ask explicitly systemctl will tell you it is enabled.

So... is there a way to get systemd to display a list of ALL the services it will attempt to run at boot, including legacy scripts?

  • 1
    Does systemctl list-units --type service --all work for you? Dec 18 '17 at 7:26
  • 3
    Newer versions of systemd may include legacy services in list-unit-files. For example, Debian 9 (Stretch) has systemd version 232. However, I only have one LSB service on that system: raspi-config.service. It is enabled, but its state is generated. It is listed when I run systemctl list-unit-files --state=generated. But now we have a new wrinkle: a service that is-enabled but whose state is not enabled. So it appears there is not a one-to-one mapping between being enabled and having a state of enabled.
    – mpb
    Dec 18 '17 at 23:43

I believe the command you want is:

systemctl list-units --type service --all

This from my test lists all service even those from legacy boot services.



  • 2
    I believe systemctl list-units --type service --all will list all services, not all enabled services. I just want enabled services, i.e., services that systemd will attempt to start at boot.
    – mpb
    Dec 18 '17 at 23:33
  • For me just running this works, and lists all "loaded" services, which AFAICT includes everything it attempted to load at boot time, ref: digitalocean.com/community/tutorials/… maybe it's a version thing...
    – rogerdpack
    May 8 '19 at 20:15

I believe what you want is

systemctl list-unit-files --type service --state enabled

Use list-unit-files to list installed unit files (not only the ones currently in memory). Some related sections from man page:

  list-units [PATTERN...]             List units currently in memory

  list-unit-files [PATTERN...]        List installed unit files
  is-enabled UNIT...                  Check whether unit files are enabled

-t --type=TYPE         List units of a particular type
   --state=STATE       List units with particular LOAD or SUB or ACTIVE state

-a --all               Show all properties/all units currently in memory,
                       including dead/empty ones. To list all units installed
                       on the system, use 'list-unit-files' instead.

On old versions of systemd this wasn't true:

In really old systemd versions "systemctl list-unit-files" only showed native unit files. In newer versions we also display generated unit files, to make them more discoverable.

I tested each generated services with is-enabled. Some return enabled, some disabled, and some a third state "generated" (which all are). I'm not sure about those.

systemctl is-enabled $(systemctl list-unit-files --type service --state generated | awk '/.*\.service/ {print $1}' | tr '\n' ' ') |& grep "^\w*$" | sort | uniq -c | sort -rn

Related links

  • Thanks for the answer. It's been so long since I asked the question that I may no longer have easy access to a system on which I can test your answer. When I asked the question, I was (probably) running Ubuntu 16.04, but I am now running 20.04 and 21.04, and the grub example in my question no longer works as it did back on 16.04.
    – mpb
    Oct 29 '21 at 19:18

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.