4

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?

Consider:

$ 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
enabled

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? – George Udosen Dec 18 '17 at 7:26
  • 2
    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
1

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.

Source:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-services

  • 1
    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 at 20:15

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.