[systemd-devel] systemctl list all possible (including unloaded) services

Roger Pack rogerdpack2 at gmail.com
Fri May 10 19:27:54 UTC 2019


On Fri, May 10, 2019 at 10:04 AM Zbigniew Jędrzejewski-Szmek
<zbyszek at in.waw.pl> wrote:
>
> On Fri, May 10, 2019 at 09:27:17AM -0600, Roger Pack wrote:
> > Hello, I'm trying to answer this question:
> >
> > https://unix.stackexchange.com/questions/517872/systemctl-list-all-possible-including-disabled-services
> >
> > Basically, I have a my_service.service that is disabled, I wish I
> > could "see that it is an option to start" by running systemctl, but it
> > doesn't seem to show up in any incantation of queries.  The reason
> > being I wanted to check that some /etc/init.d/XX scripts "had an
> > autogenerated service equivalent or not" and some were showing up in
> > the systemctl lists and some weren't (the disabled ones weren't, even
> > though still controllable by systemctl).  It was some newbie confusion
> > but still...confusing.
> >
> > My hunch is that since it isn't auto started it is never "loaded" and
> > then doesn't appear in any query (if this is the case I really wish a
> > new command could be created to "list all units installed on the
> > system").
> >
> > systemd 219 in this case.
>
> Seems to work here. I have just one sysvinit script:
> $ ls /etc/init.d/
> functions  network  README
> $ systemctl list-unit-files 'network*'
> UNIT FILE             STATE
> network.service       generated
> ...
> $ systemctl cat network.service
> # /run/systemd/generator.late/network.service
> # Automatically generated by systemd-sysv-generator
> ...
> $ systemctl start network<TAB> # autocompletes to network.service
>
> $ systemctl --version
> systemd 241 (v241-7.gita2eaa1c.fc30)

Interesting.  I tried the following on a Debian 8 box, where
/etc/init.d/sysstat exists

# systemctl --version
systemd 215
# systemctl enable sysstat
Synchronizing state for sysstat.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d sysstat defaults
Executing /usr/sbin/update-rc.d sysstat enable
# systemctl list-unit-files | grep sysstat
(empty, even if it's enabled)
# systemctl
However on a Debian 9 box:
# systemctl --version
systemd 232
# systemctl list-unit-files | grep sysstat
sysstat.service                        generated

It's always listed even if it's disabled.

Unfortunately I can't easily test a CentOS box with a newer systemctl
since its version of libmount seems stuck at "old" version 2.32.  But
for now hoping it was just a bug fixed in later versions.  Also of
note is that with older versions of systemctl, as expected, if it
"attempted" to autostart an init.d but failed, it would still show up
in the output of `systemctl list-units`, but never in the output of
list-unit-files, which is what gave me the initial impression it
wasn't available at all if it didn't autostart.
Thanks all for the feedback and help!

-Roger Pack-


More information about the systemd-devel mailing list