DPKG Version Number – How to Find the Version Number of an Installed Package via DPKG

command linedpkg

I use the dpkg -l command to find out what version of a package I have installed. For example:

dpkg -l network-manager

returns the information on the package:

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                   Description
+++-=========================-=========================-==================================================================
ii  network-manager           0.8.3~git.20101118t223039 network management framework daemon

As you can see, it returns 0.8.3~git.20101118t223039 which is wrong because it truncates the version (I've picked a long one for the purpose of this question). The way I've solved this in the past is to pass a stupidly long COLUMNS argument to make it expand:

COLUMNS=200 dpkg -l network-manager

which gives me the entire version number, but also a bunch of junk:

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                                      Description
+++-============================================-============================================-========================================================================================================
ii  network-manager                              0.8.3~git.20101118t223039.d60a988-0ubuntu1   network management framework daemon

Now I can see the full version number, which is 0.8.3~git.20101118t223039.d60a988-0ubuntu1.

I get the feeling that this is not the proper way to find the version number of an installed package. This never really was a problem in the past, but with the tacking on of "ubuntu" in the versions and the proliferation of PPAs these strings are getting longer and longer. Is there an easier way?

Best Answer

dpkg -s <packagename> | grep '^Version:'

e. g.:

dpkg -s network-manager | grep '^Version:'

Sample output:

Version: 0.8.1+git.20100810t184654.ab580f4-0ubuntu2
Related Question