241

How can I check the version of the available package in the Ubuntu repositories without installing it?

311

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.

24

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.

13
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
8

Open your terminal with CTRL+ALT+T and then type as

apt-cache showpkg <package_name>

Then it will give you information about whats the available version.

for example:

jai@frank-Jai:~$ apt-cache showpkg chromium
Package: chromium
Versions: 

Reverse Depends: 
  mozplugger,chromium 10.0.648.114~r75702-1~
  chromium-bsu,chromium 0.9.14
  chromium-bsu,chromium 0.9.14
Dependencies: 
Provides: 
Reverse Provides: 
jai@frank-Jai:~$ 
  • 1
    As far as I know, there is no such a package named only "chromium". Therefore apt-cache show is more practical in this sense. – Radu Rădeanu Sep 2 '13 at 19:52
  • @RaduRădeanu chromium is a browser. – rɑːdʒɑ Sep 5 '13 at 15:06
  • 1
    Yes, you have right, but the name of the package is chromium-browser. You can check with apt-cache search chromium. It's the 5th line from the output :) – Radu Rădeanu Sep 5 '13 at 15:15
7

apt-cache show or aptitude show gives you a lot of information about a package from your repositories (even if this is installed or not), including the version. If you are interested only about version, use:

apt-cache show <packageName> | grep Version

or

aptitude show <packageName> | grep Version

If a package is available in several versions, you will see this. To see only the last version, use:

apt-cache show <packageName> | grep Version | head -1

You can not have any doubts with the above command.

2
apt-cache policy <PackageName> | grep Candidate | cut -d ':' -f 3 | cut -d '-' -f 1
  • 4
    Would be nice if you would edit your answer to include a brief description what your command and its sub parts do, so future readers may get some insight, not everyone is savvy enough to understand what you do there. Cheers. – Videonauth Jul 1 '16 at 10:53
0

Here's another way:

sudo apt-get -s install --only-upgrade <package-name>

The above method only works if run with sudo.

  • 2
    I don't think you need sudo for this, since you're just simulating (-s) – Gerhard Burger Jun 21 '16 at 19:42
  • 2
    You do if the user you're running the command as doesn't have read access to the files in /etc/apt/sources.list.d/ Same as if you run apt-cache policy <pkg name> In my case, I had to run with sudo – Jerry Hoffmeister Aug 3 '16 at 18:07

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.