5

Question just out of curiosity.

According to RHEL7 System Administration Guide (https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Services.html#sect-Managing_Services_with_systemd-Services-List)

The following command should list all loaded units

systemctl list-units --type service --all

But in fact it doesn't list all loaded services, only those which are enabled OR active OR (active AND enabled).

For example:

[root@roman-centos system]# systemctl list-units --type service --all | grep httpd
[root@roman-centos system]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
           man:apachectl(8)

Is it the way it is supposed to be or it might be documentation/code bug?

0

2 Answers 2

7

"Loaded" means that systemd has the read the unit from disk into memory. This will happen whenever you "look" at the unit, e.g. with status, when the unit is started, or when the unit is a dependency of another unit that is loaded.

The misunderstanding here is that 'systemctl status' will always show the unit as "loaded", because systemd loads the unit to display the status. If the unit is not needed for anything else, it will be unloaded immediately after.

If you want to display all a list of all possible units found on disk, use 'systemctl list-unit-files'.

0

The authoritative docs for systemctl would not be the Red Hat docs but man systemctl. According to man systemctl:

`--type service` should "limit the output to only services."
`--all` should "how all loaded units, regardless of their state, including inactive units. "

So the command you've given should list all loaded service units, regardless of their state, including inactive units.

Testing on Ubuntu 16.04 with systemd version 229, I reproduced the issue with loaded-but-disabled units not being reported in the output, which does match the documented behavior.

Since the behavior does match the documentation, this appears to be a bug in systemd. I've opened a bug report with systemd about this issue.

5
  • 2
    Thanks, Mark. Yes, you can see inactive services, but only if they are not disabled. Try to stop and disable some service and you won't see it in the list. But systemctl status <service_name> command will still show it as loaded. I've just tested it on Ubuntu 16.10 SystemD version 231.
    – Roman_T
    Commented Jan 11, 2017 at 3:37
  • 1
    @Roman_T thanks for the feedback. This appears to be bug in systemd. I've updated my answer accordingly and opened a bug report in the systemd bug queue. Commented Jan 11, 2017 at 15:41
  • thanks. I've just opened the same bug report just before you. github.com/systemd/systemd/issues/5063 =). So I guess you can close yours.
    – Roman_T
    Commented Jan 11, 2017 at 21:45
  • Ah. I also created an Issue with systemd to improve their documentation of the systemctl status command to better explain what the different terms in the output mean. Commented Jan 12, 2017 at 1:51
  • I have a question regarding this, where my process is stopped but still broadcasting dlna: superuser.com/questions/1482275/…
    – bomben
    Commented Sep 20, 2019 at 14:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .