Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to know how to get the version information of an installed program that doesn't have the

--version or -version

method implemented.

share|improve this question
I know you mean for any program, but can you say which program exactly? – user8290 Jan 28 '12 at 14:53
up vote 15 down vote accepted

You can use dpkg or apt-cache.

To check the version of bash, for example:

dpkg -l bash

apt-cache show bash
share|improve this answer
For those just looking for general Linux answers, the equivalent to the above for RHEL/CentOS/Fedora (and similar) would be yum requires <file> e.g. yum requires ssh-keygen would give you your openSSH version. – SeldomNeedy Apr 28 at 20:31
@SeldomNeedy - yum is depreciated on Fedora, Fedora uses dnf. Centos/RHEL still on yum. – bodhi.zazen Apr 28 at 21:18

If the program doesn't have any command line option that displays version information you can try to use dpkg to get the package version which usually contains the program version ion some way.

dpkg -S "$(which YOUR_PROGRAM)"

prints the package that contains YOUR_PROGRAM, and

dpkg --status YOUR_PACKAGE | grep ^Version

prints the version of YOUR_PACKAGE.

You can put it all together:

dpkg --status "$(dpkg -S "$(which YOUR_PROGRAM)" | cut -d: -f1)" | grep ^Version

Use it for example like this for ls:

dpkg --status "$(dpkg -S "$(which ls)"| cut -d: -f1)"| grep ^Version
share|improve this answer
As a suggestion. Put it all in a function and load it when your shell starts. – Zoke Jan 28 '12 at 16:03

The below command also gives you the exact installed package version.

apt-cache policy <package-name> | grep Installed: | cut -d: -f2


$ apt-cache policy firefox | grep Installed: | cut -d: -f2

$ apt-cache policy gedit | grep Installed: | cut -d: -f2
share|improve this answer

You can use dpkg-query to get the version of a package:

$ dpkg-query -W -f='${binary:Package} ${Version}\n' firefox
firefox 29.0+build1-0ubuntu0.13.10.3

To only get the version string:

$ dpkg-query -W -f='${Version}\n' firefox
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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