Debian get version of running services

2

How to get the version number of running services in Debian ?

service --status-all

does not give it.

kursus

Posted 2013-11-07T01:15:16.613

Reputation: 123

Answers

1

The services running on Debian or on any GNU/Linux box for that matter don't necessarily have a version themselves. Instead all daemons which provide services have some kind of a version string and are part of some package. The former is rather difficult to dig out as not all daemons, though most of them, answer to obvious command line switches like --version or -v the way one might expect. The latter is somewhat easier: we can just take a list of all init-scripts starting the various daemons and then list package information for those files.

This is not exactly what you asked for, but comes quite close. At least you'll know which package versions provide which services. The following example will produce a listing of all packages which provide an init-script or -scripts in the directory /etc/init.d/.

#!/bin/sh

for pkg in $(for file in /etc/init.d/* ; do \
               dpkg -S $file | awk -F: '{ print $1 }' ; \
             done | sort | uniq) ; do
  echo "$pkg: `dpkg-query -W -f='${Version}' $pkg`"
done

This will take some time to get through, dpkg isn't the fastest thing on the planet and it gets run quite a many times there. There will also be some things listed by service --status-all which aren't displayed by the example above. This is simply because we're querying each package only once (because of uniq there): some packages provide several init-scripts and this is reflected then on the output of service --status-all.

Sami Laine

Posted 2013-11-07T01:15:16.613

Reputation: 1 002

Thank you for you complete answer. The script works well. – kursus – 2013-11-07T15:05:31.540