Skip to main content
3 of 5
debugged
Kamil Maciorowski
  • 24.5k
  • 2
  • 69
  • 129

If you are on a debian based distrobution, you can use the package manager to figure it out:

$ dpkg -S $(which man)
man-db: /usr/bin/man

This tells us man-db is the package which owns /usr/bin/man.

$ dpkg -l man-db
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  man-db         2.10.2-1     amd64        tools for reading manual pages

Then we ask what version of man-db is installed. This is man-db's upstream version 2.10.2 released by the distribution with an extra -1. The -1 represents a patch done by the distribution. This may just include build-rules, but could also include fixes to 2.10.2 ported from later versions.

If you want a 1-liner, you could put it all togeather:

dpkg -l $(dpkg -S $(which man) | sed 's/:.*$//' ) | grep ^ii | awk '{ print $3 }'
2.10.2-1

Or a function which could go into .bashrc:

ver() {
  binary=$(which "$1")
  package=$(dpkg -S "$binary" | sed 's/:.*$//')
  version=$(dpkg -l "$package" | grep ^ii | awk '{ print $3 }')
  printf "%s\n" "$version"
}

ver man
2.10.2-1
Stewart
  • 16k
  • 5
  • 49
  • 101