How to Identify the Package version before Installing using a apt-get or aptitude in Ubuntu?

Updated on September 2, 2017

Few days ago, I wrote an article on yum commands that allows you to know the version of the package available in the repository. Today I’ll be showing how to use apt-get and aptitude commands in Ubuntu to identify the version of the package before installing. I mean, you can use simulation option with apt-get to know the exact version of the package that will be installed and when you use apt-get upgrade, it will show the complete list of package that will be upgraded with its version information. The same can be achieved using aptitude command as well. Well, here are the commands.

You can use ‘-s’ (simulation) option with apt-get as shown below to know the version of the package before installing. For e.g, assume that you would like to know the version of vim that’s available in the repository even before you install it.

apt-get examples

How to identify the package version before installing using apt-get?

# apt-get -s install vim
 The following extra packages will be installed:
 vim-common vim-runtime vim-tiny
 Suggested packages:
 ctags vim-doc vim-scripts indent
 The following NEW packages will be installed:
 vim vim-runtime
 The following packages will be upgraded:
 vim-common vim-tiny
 2 upgraded, 2 newly installed, 0 to remove and 487 not upgraded.
 Inst vim-tiny [2:7.3.154+hg~74503f6ee649-2ubuntu3] (2:7.3.154+hg~74503f6ee649-2ubuntu3.1 Ubuntu:11.10/oneiric-updates [amd64]) []
 Inst vim-common [2:7.3.154+hg~74503f6ee649-2ubuntu3] (2:7.3.154+hg~74503f6ee649-2ubuntu3.1 Ubuntu:11.10/oneiric-updates [amd64])
 Inst vim-runtime (2:7.3.154+hg~74503f6ee649-2ubuntu3.1 Ubuntu:11.10/oneiric-updates [all])
 Inst vim (2:7.3.154+hg~74503f6ee649-2ubuntu3.1 Ubuntu:11.10/oneiric-updates [amd64])
 Conf vim-common (2:7.3.154+hg~74503f6ee649-2ubuntu3.1 Ubuntu:11.10/oneiric-updates [amd64])
 Conf vim-tiny (2:7.3.154+hg~74503f6ee649-2ubuntu3.1 Ubuntu:11.10/oneiric-updates [amd64])
 Conf vim-runtime (2:7.3.154+hg~74503f6ee649-2ubuntu3.1 Ubuntu:11.10/oneiric-updates [all])
 Conf vim (2:7.3.154+hg~74503f6ee649-2ubuntu3.1 Ubuntu:11.10/oneiric-updates [amd64])

The above output shows the version information of the dependent packages as well.

The same option can be used with apt-get upgrade as well. Here, the command will display all possible packages (along with its version information) that are going to be upgraded.

# apt-get -V -s upgrade

Using apt-cache:

You can use policy attribute with apt-cache command to know the version of the package that’s installed in the system and as well as in the repository.

# apt-cache policy vim
 Installed: (none)
 Candidate: 2:7.3.154+hg~74503f6ee649-2ubuntu3.1
 Version table:
 2:7.3.154+hg~74503f6ee649-2ubuntu3.1 0
 500 oneiric-updates/main amd64 Packages
 2:7.3.154+hg~74503f6ee649-2ubuntu3 0
 500 oneiric/main amd64 Packages

Using aptitude:

Use versions attribute with aptitude to know the version of the package before installing.

# aptitude versions thunderbird
 i   7.0.1+build1+nobinonly-0ubuntu1                  oneiric                              500
 p   17.0.5+build1-0ubuntu0.11.10.1                    oneiric-security,oneiric-updates
# aptitude -V -s install <package>

Using -V will give you the detailed information.

Was this article helpful?

Related Articles

Leave a Comment