4

I'd like to list all enabled service instances.

The following lists enabled services, but only shows the service, and not individual instance:

systemctl list-unit-files --state=enabled

The following lists all running instances:

systemctl list-units --state=running

I would expect something like the following to show enabled instances:

systemctl list-units --state=enabled

But that does not work.

So, if I start two service instances with:

systemctl start foo-service@primary
systemctl start foo-service@secondary

...but then I only enable one:

systemctl enable foo-service@secondary

The only way I've been able to find out which instances are enabled is with:

ls /etc/systemd/system/multi-user.target.wants/

But that seems very kludge-y. Is there a systemd way of doing this? Version is 237 if it matters.

rich remer
  • 449
  • 4
  • 11

1 Answers1

1

I'm pretty sure you're looking for systemctl list-units --state=loaded.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • That seems to come back with false positives. For example, using that method I am seeing a service in `loaded failed failed` state for a unit where `is-enabled` comes back as `static`. – rich remer Jul 22 '19 at 20:18