How can I check the available version of a package in the repositories?

Use the command:

apt-cache policy <packageName>

This gives you information of all available package versions.

Example:

alaa@aa-lu:~$ apt-cache policy vlc
vlc:
  Installed: 2.0.8-0ubuntu0.13.04.1
  Candidate: 2.0.8-0ubuntu0.13.04.1
  Version table:
 *** 2.0.8-0ubuntu0.13.04.1 0
        500 http://ae.archive.ubuntu.com/ubuntu/ raring-updates/universe i386 Packages
        500 http://security.ubuntu.com/ubuntu/ raring-security/universe i386 Packages
        100 /var/lib/dpkg/status
     2.0.6-1 0
        500 http://ae.archive.ubuntu.com/ubuntu/ raring/universe i386 Packages
  • From the output, you can see that there are two versions available: 2.0.8-0ubuntu0.13.04.1 and 2.0.6-1. It also tells you which repositories they are coming from.

  • Installed: tells you the version you have installed. If you don't have the package installed, you'll see (none).

  • Candidate: is the version that will be installed if you use apt-get install vlc. If you want to install the other version, you would do apt-get install vlc=2.0.6-1.


Go to packages.ubuntu.com, fill in the search form and get a nice view of the package including the version.


enter image description here


Hit search, then:


enter image description here


Additional benefits

  • Will also list versions of packages for other versions of Ubuntu. Eg. if you want to know about the version of the package in Raring (13.04), but your system still has Precise (12.04), then this will provide a way to find it out.
  • You don't even need Ubuntu to be installed.

Biggest downside is that it won't list the versions of other repositories you possible have installed, such as PPAs. You will then need the apt-cache policy approach as already posted.

Pro tip

Take the shortcut - just browse to http://packages.ubuntu.com/packagename and replace packagename with the name of the package you want to query.


apt-cache madison <packageName>

It also gives information about all available package versions in the repositories. This command output had the syntax like this:

packageName | Version | Repository

apt-cache's madison command attempts to mimic the output format and a subset of the functionality of the Debian archive management tool, madison. It displays available versions of a package in a tabular format. Unlike the original madison, it can only display information for the architecture for which APT has retrieved package lists (APT::Architecture).

Example:

$ apt-cache madison chromium-browser
chromium-browser | 32.0.1700.102-0ubuntu0.13.10.1~20140128.970.1 | http://mirror.sov.uk.goscomb.net/ubuntu/ saucy-updates/universe amd64 Packages
chromium-browser | 32.0.1700.102-0ubuntu0.13.10.1~20140128.970.1 | http://mirror.sov.uk.goscomb.net/ubuntu/ saucy-security/universe amd64 Packages
chromium-browser | 29.0.1547.65-0ubuntu2 | http://mirror.sov.uk.goscomb.net/ubuntu/ saucy/universe amd64 Packages
chromium-browser | 29.0.1547.65-0ubuntu2 | http://archive.ubuntu.com/ubuntu/ saucy/universe amd64 Packages
chromium-browser | 29.0.1547.65-0ubuntu2 | http://mirror.sov.uk.goscomb.net/ubuntu/ saucy/universe Sources
chromium-browser | 32.0.1700.102-0ubuntu0.13.10.1~20140128.970.1 | http://mirror.sov.uk.goscomb.net/ubuntu/ saucy-updates/universe Sources
chromium-browser | 32.0.1700.102-0ubuntu0.13.10.1~20140128.970.1 | http://mirror.sov.uk.goscomb.net/ubuntu/ saucy-security/universe Sources
chromium-browser | 29.0.1547.65-0ubuntu2 | http://archive.ubuntu.com/ubuntu/ saucy/universe Sources
chromium-browser | 29.0.1547.65-0ubuntu2 | http://archive.ubuntu.com/ubuntu/ saucy/universe Sources