I want to list all the packages(installed or not installed) along with the latest version number available in the repositories.

For example:

The output of apt-cache policy chromium-browser shows like below

$ apt-cache policy chromium-browser
  Installed: (none)
  Candidate: 34.0.1847.116-0ubuntu2
  Version table:
     34.0.1847.116-0ubuntu2 0
        500 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty/universe amd64 Packages

So the latest version of chromium-browser package available in the repository is 34.0.1847.116-0ubuntu2. Like that, i want to list the version number along with the package names that are available in repositories. And all i want to do this through command-line.

I want the output to be like this,

chromium-browser 34.0.1847.116-0ubuntu2
xxxxxxxxxxxxxx   yyyyyyyyyyy
............     ............

4 Answers 4


apt-cache policy '.*' displays detailed version information for all packages.

If you want a more compact output with one line per package, you can use aptitude. The following command lists available versions (see the manual for output format specifications) for all packages except cross-architecture ones (e.g. 32-bit packages on a 64-bit system) (see the manual for search patterns):

aptitude search -F '%54p %24V' '~rnative'

apt-cache dump

N.B.: This is a very large output. You will want to use a pager like less, or redirect this output to a file.

  • Additionally, you can find information on command-line options and syntax for almost every command, including apt-get and apt-cache by calling the man command, which would have answered this question for you, and may be of use to you in the future.
    – James S.
    May 29, 2014 at 14:50

The below command will list all the available packages along with their latest version numbers available in repositories.

for i in $(apt-cache search all | awk -F' - ' '{print $1}'); do apt-cache policy $i | sed -n '1,3p' | sed ':a;N;s/\n//g;ba'; done | awk '{print $1,$5}'


$ for i in $(apt-cache search all | awk -F' - ' '{print $1}'); do apt-cache policy $i | sed -n '1,3p' | sed ':a;N;s/\n//g;ba'; done | awk '{print $1,$5}'
acpica-tools: 20140214-1ubuntu1
acpid: 1:2.0.21-1ubuntu2
activity-log-manager: 0.9.7-0ubuntu14
adduser: 3.113+nmu3ubuntu3
advancecomp: 1.18-1
aide: 0.16~a2.git20130520-2
aide-common: 0.16~a2.git20130520-2
alembic: 0.6.2+ds-1
alien: 8.90
alsa-base: 1.0.25+dfsg-0ubuntu4
amavisd-new: 1:2.7.1-2ubuntu3
anacron: 2.3-20ubuntu1
android-headers: 4.2.2-2-0ubuntu1
android-tools-fsutils: 4.2.2+git20130218-3ubuntu23
antlr: 2.7.7+dfsg-5
apache2: 2.4.7-1ubuntu4
apache2-bin: 2.4.7-1ubuntu4
apache2-dev: 2.4.7-1ubuntu4
apache2-mpm-event: 2.4.7-1ubuntu4
apache2-mpm-prefork: 2.4.7-1ubuntu4
apache2-mpm-worker: 2.4.7-1ubuntu4
apache2-utils: 2.4.7-1ubuntu4
apache2.2-bin: 2.4.7-1ubuntu4
apg: 2.2.3.dfsg.1-2ubuntu1

I take the first package and then do apt-cache policy on that, it displays the same version number as displayed by the above for command,

$ apt-cache policy acpica-tools
  Installed: (none)
  Candidate: 20140214-1ubuntu1
  Version table:
     20140214-1ubuntu1 0
        500 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty/main amd64 Packages

This seems to accomplish what you're asking.

gawk '/^Package:/{printf $2 "\t"} /^Version:/{print $2}' /var/lib/dpkg/available

It should be somewhat faster than parsing the output of another command too. If you want to mess with the formatting (for package: version — note that's not what your question asks for), you can change the first printf to:

printf $2 ": "

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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