list enabled systemd service instances

rich remer asked:

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 [email protected]
systemctl start [email protected]

…but then I only enable one:

systemctl enable [email protected]

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

ls /etc/systemd/system/

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

My answer:

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

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.