13

Which systemctl option or command would I use to display a summary of all services currently running?

1
  • You should accept @Zanna s answer. it far more addressing your question as mine does, even if its a valid approach too. – Videonauth Nov 14 '17 at 17:34
22

You could use some of systemctl's options:

-t, --type=
       The argument should be a comma-separated list of unit types such as
       service and socket.

       If one of the arguments is a unit type, when listing units, limit
       display to certain unit types. Otherwise, units of all types will
       be shown.

       As a special case, if one of the arguments is help, a list of
       allowed values will be printed and the program will exit.

   --state=
       The argument should be a comma-separated list of unit LOAD, SUB, or
       ACTIVE states. When listing units, show only those in the specified
       states. Use --state=failed to show only failed units.

       As a special case, if one of the arguments is help, a list of
       allowed values will be printed and the program will exit.

So probably you want:

systemctl --type=service --state=active list-units

Which lists all active services including those which have exited. If you're only after the ones running at this moment you could use:

systemctl --type=service --state=running list-units
1
  • 4
    The systemctl command without any subcommands assumes list-units, so... systemctl --type-service --state=running, or just a plain systemctl for quick use. – muru Nov 15 '17 at 1:43
12

It is (see man 1 systemctl):

systemctl list-units | grep -E 'service.*running'

or (see also man 8 service)

service --status-all

Where the [+] indicates services which are actually running.

5

After looking around for longer than necessary I came up with this slightly different method of determining running services. It also shows how to count the number of running services. This way ensures that its not accidentally catching something with the word running or service in the services name itself.

# Output all active services:
systemctl -t service --state=active --no-pager --no-legend

# Count of all active services:
systemctl -t service --state=active --no-pager --no-legend | grep -c -

# Output all running services:
systemctl -t service --state=active --no-pager --no-legend | egrep '^*\.service.*running'

# Count of all running services:
systemctl -t service --state=active --no-pager --no-legend | egrep '^*\.service.*running' -c -

# Output only the service and its description:
systemctl -t service --state=active --no-pager --no-legend | egrep '^*\.service.*running' | awk 'BEGIN { FS = " ";} {for (i = 2; i <= 4; i++) { $i = "" }; print}'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.