While working to verify some packages in Ubuntu 12.04 had backport patches installed properly I needed to list installed package versions. To do this you can install a package called apt-show-versions which will allow you to list all installed packages and their versions with ease. This likely works on most Ubuntu versions but was tested on Ubuntu 12.04 also know as Precise PangolinĀ and Ubuntu 12.10 also known as Quantal Quetzal. Follow the instructions below to install apt-show-versions and then list all installed packages and their versions.
Install apt-show-versions On Ubuntu To List Package Versions:
- root@dev:/etc/apache2# apt-get install apt-show-versions
- Reading package lists... Done
- Building dependency tree
- Reading state information... Done
- The following extra packages will be installed:
- libapt-pkg-perl
- The following NEW packages will be installed:
- apt-show-versions libapt-pkg-perl
- 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
- Need to get 115 kB of archives.
- After this operation, 420 kB of additional disk space will be used.
- Do you want to continue [Y/n]? Y
- Get:1 http://azure.archive.ubuntu.com/ubuntu/ quantal/main libapt-pkg-perl amd64 0.1.26 [81.8 kB]
- Get:2 http://azure.archive.ubuntu.com/ubuntu/ quantal/universe apt-show-versions all 0.19+nmu1 [33.5 kB]
- Fetched 115 kB in 0s (263 kB/s)
- Selecting previously unselected package libapt-pkg-perl.
- (Reading database ... 56372 files and directories currently installed.)
- Unpacking libapt-pkg-perl (from .../libapt-pkg-perl_0.1.26_amd64.deb) ...
- Selecting previously unselected package apt-show-versions.
- Unpacking apt-show-versions (from .../apt-show-versions_0.19+nmu1_all.deb) ...
- Processing triggers for man-db ...
- Setting up libapt-pkg-perl (0.1.26) ...
- Setting up apt-show-versions (0.19+nmu1) ...
- ** initializing cache. This may take a while **
- root@dev:/etc/apache2#
Now that the package is installed you should be able to list the Ubuntu installed package versions as shown in the below example.
List Installed Package Versions In Ubuntu 12.04:
- root@dev:/etc/apache2# apt-show-versions
- accountsservice/quantal-updates uptodate 0.6.21-6ubuntu5.1
- acpid/quantal uptodate 1:2.0.16-1ubuntu1
- adduser/quantal uptodate 3.113+nmu1ubuntu1
- apache2/quantal-security uptodate 2.2.22-6ubuntu2.3
- apache2-mpm-prefork/quantal-security uptodate 2.2.22-6ubuntu2.3
- apache2-utils/quantal-security uptodate 2.2.22-6ubuntu2.3
- apache2.2-bin/quantal-security uptodate 2.2.22-6ubuntu2.3
- apache2.2-common/quantal-security uptodate 2.2.22-6ubuntu2.3
- apparmor/quantal-updates uptodate 2.8.0-0ubuntu5.1
- apport/quantal-updates uptodate 2.6.1-0ubuntu11
- apport-symptoms/quantal uptodate 0.19
- apt/quantal-security uptodate 0.9.7.5ubuntu5.4
- apt-show-versions/quantal uptodate 0.19+nmu1
- apt-transport-https/quantal-security uptodate 0.9.7.5ubuntu5.4
- apt-utils/quantal-security uptodate 0.9.7.5ubuntu5.4
- apt-xapian-index/quantal uptodate 0.44ubuntu7
- aptitude/quantal uptodate 0.6.8.1-2ubuntu1
- aptitude-common/quantal uptodate 0.6.8.1-2ubuntu1
- at/quantal uptodate 3.1.13-2ubuntu1
- base-files/quantal-updates uptodate 6.5ubuntu12
- base-passwd/quantal uptodate 3.5.26
- bash/quantal uptodate 4.2-5ubuntu1
- bash-completion/quantal uptodate 1:2.0-1ubuntu2
- bc/quantal uptodate 1.06.95-4
- bind9-host/quantal-security uptodate 1:9.8.1.dfsg.P1-4.2ubuntu3.2
- bsdmainutils/quantal uptodate 9.0.3ubuntu1
- bsdutils/quantal uptodate 1:2.20.1-5.1ubuntu2
- busybox-initramfs/quantal-updates uptodate 1:1.19.3-7ubuntu1.1
- busybox-static/quantal-updates uptodate 1:1.19.3-7ubuntu1.1
- byobu/quantal uptodate 5.21-0ubuntu1
- bzip2/quantal uptodate 1.0.6-4
- ca-certificates/quantal uptodate 20120623
- cloud-init/quantal-updates uptodate 0.7.0-0ubuntu2.3
- cloud-initramfs-growroot/quantal uptodate 0.18-ubuntu1
- cloud-utils/quantal uptodate 0.26-0ubuntu1
- command-not-found/quantal uptodate 0.3ubuntu5
- command-not-found-data/quantal uptodate 0.3ubuntu5
- console-setup/quantal uptodate 1.70ubuntu6
- consolekit/quantal-updates uptodate 0.4.5-3ubuntu0.1
- coreutils/quantal-updates uptodate 8.13-3.2ubuntu2.1
- cpio/quantal uptodate 2.11-8ubuntu3
- crda/quantal uptodate 1.1.2-1ubuntu2
- cron/quantal uptodate 3.0pl1-121ubuntu1
- cryptsetup/quantal uptodate 2:1.4.3-2ubuntu1
- cryptsetup-bin/quantal uptodate 2:1.4.3-2ubuntu1
- curl/quantal-security uptodate 7.27.0-1ubuntu1.3
- dash/quantal uptodate 0.5.7-3ubuntu1
- dbus/quantal-security uptodate 1.6.4-1ubuntu4.1
- debconf/quantal uptodate 1.5.46ubuntu1
- debconf-i18n/quantal uptodate 1.5.46ubuntu1
- debianutils/quantal uptodate 4.3.4
- diffutils/quantal uptodate 1:3.2-6ubuntu1
- distro-info/quantal uptodate 0.10
- distro-info-data/quantal-updates uptodate 0.10ubuntu3
- dmidecode/quantal uptodate 2.11+20120326-2
- dmsetup/quantal-updates uptodate 2:1.02.74-4ubuntu1.1
- dnsutils/quantal-security uptodate 1:9.8.1.dfsg.P1-4.2ubuntu3.2
- dosfstools/quantal uptodate 3.0.13-1
- dpkg/quantal uptodate 1.16.7ubuntu6
- e2fslibs/quantal uptodate 1.42.5-1ubuntu2
- e2fsprogs/quantal uptodate 1.42.5-1ubuntu2
- ed/quantal uptodate 1.6-2
- eject/quantal uptodate 2.1.5+deb1+cvs20081104-11
- ethtool/quantal uptodate 1:3.4.1-1
- euca2ools/quantal-updates uptodate 2.0.2-1ubuntu2.1
- file/quantal uptodate 5.11-2
- findutils/quantal uptodate 4.4.2-4ubuntu2
- fonts-ubuntu-font-family-console/quantal uptodate 0.80-0ubuntu5
- friendly-recovery/quantal uptodate 0.2.25
- ftp/quantal uptodate 0.17-27
- fuse/quantal uptodate 2.9.0-1ubuntu2
- gcc-4.7-base/quantal uptodate 4.7.2-2ubuntu1
- ...
- wireless-tools/quantal uptodate 30~pre9-8ubuntu1
- wpasupplicant/quantal uptodate 1.0-2ubuntu5
- xauth/quantal uptodate 1:1.0.7-1
- xkb-data/quantal uptodate 2.5-1ubuntu7
- xml-core/quantal uptodate 0.13+nmu1
- xz-utils/quantal uptodate 5.1.1alpha+20120614-1
- zip/quantal uptodate 3.0-6
- zlib1g/quantal uptodate 1:1.2.7.dfsg-13
- root@dev:/etc/apache2#
The above example has many of the results filtered out but you now should be able to list Ubuntu 12.04 package versions with ease. To list a single package version such as Apache2 you could use grep as shown in the below example.
List Single Package Version Ubuntu 12.04:
- root@dev:/etc/apache2# apt-show-versions | grep apache2\/
- apache2/quantal-security uptodate 2.2.22-6ubuntu2.3
- root@dev:/etc/apache2#
You could just use dpkg-query –list | grep {packagename}