Systemctl – List All Services Including Disabled

systemctlsystemd

I have a "service" that originates from an /etc/init.d/XX script, and a systemd wrapper is generated for it. It doesn't autostart in any runlevel, and when I run systemctl --all or systemctl list-unit-files --all it doesn't show up in any list.

My hunch is that because it has no dependencies, hasn't been started, it isn't "loaded" into systemd (so not enabled, not loaded) so systemd doesn't list it.

Is there a way to get a full list of all possible services, even those not yet started and that aren't auto-started? Or do a systemctl search equivalent?

This related question only asks for a list of services that will be attempted at boot time.

The man page for systemctl under "–all" says

To list all units installed on the system, use the list-unit-files command instead

but these disabled units do not show up in the output of list-unit-files.

Best Answer

OK I asked "the systemd guys" and they said in old versions it didn't list them all, despite the man page saying this:

   -a, --all
       When listing units, show all loaded units, regardless of their
       state, including inactive units. When showing unit/job/manager
       properties, show all properties regardless whether they are set or
       not.

       To list all units installed on the system, use the list-unit-files
       command instead.

Most of the functionality listed above didn't seem to actually happen with "my" systemd version systemd 219 (CentOS 6). But it seems fixed in newer versions of systemctl on Debian 9 which has version systemd 232, perhaps that's why.

You can still control them like normal (status, start, stop) with the older systemd version if the init.d script does specify runlevels but is absent from all /etc/rc?.d dirs (a la chkconfig --del my_service or its equivalent systemctl disable my_service, or if chkconfig was never run initially on it) then the systemd-sysv-generator with older versions of systemd it doesn't [show up in the lists][2] if you run systemctl list-units --all etc. even though it's working fine and still controllable. Or if they're normal services but disabled they seem to also not show up in any lists, despite being still functional.

ref: https://lists.freedesktop.org/archives/systemd-devel/2019-May/042555.html

Related Question