How to check Debian/Ubuntu Linux package version using apt-get/aptitude command

I

am a new Debian / Ubuntu Linux sysadmin. I would like to find out what version I would install if I ran the apt-get command. How do I find out which versions of a package can I install using apt-cache/apt-get command? How do you check package version using apt-get/aptitude on Debian or Ubuntu Linux server?

 

There are various commands or options that can tell you about the version number on Debian or Ubuntu Linux based system.

Method #1: Check package version using apt-cache command

The syntax is:

apt-cache policy {package}

 

OR

apt-cache madison {package}

 

For example, before I install nginx package I would like to know what version of nginx I would get on my system, run:

$ apt-cache policy nginx

 

OR

$ apt-cache madison nginx

 

Fig.01: apt-cache check package version on Debian/Ubuntu Linux

Method #2: Check package version using apt command

The syntax is

apt list {package-name-here}

apt list vim

 

Sample outputs:

Listing… Done

vim/xenial,now 2:7.4.963-1ubuntu5 amd64 [installed]

I have vim package # 7.4.963 version installed on my system.

Method #3: Check package version using aptitude command

The syntax is:

aptitude versions {package-name-here}

aptitude versions {package-name-here} | more

aptitude versions {package-name-here} | awk { print $2 }

 

To find htop version you are about to install on Ubuntu server, enter:

$ aptitude versions htop

 

Sample outputs:

Package htop:

p   1.0.3-1build1                                                                               xenial                                                                   500

 

Package htop:i386:

p   1.0.3-1build1                                                                               xenial                                                                   500

Method #4: Package simulation using aptitude or apt-get command

The syntax is as follows:

aptitude -V -s install {package-name-here}

apt-get -V -s install {package-name-here}

 

No action taken. It perform a simulation of events that would occur based on the current system state but do not actually change the system. Of course, press n when prompted to avoid installation.

A note about finding version of installed packages

Use the following syntax:

apt-show-versions {package-name-here}

 

OR

dpkg -s {package-name-here}

dpkg -s {package-name-here} | grep -i version

 

To see version of install package called vim, run:

$ apt-show-versions vim

vim:amd64/xenial 2:7.4.963-1ubuntu5 uptodate

vim:i386 not installed

 

OR

$ dpkg -s vim | grep -i version

Version: 2:7.4.963-1ubuntu5

Vim is an almost compatible version of the UNIX editor Vi.

This package contains a version of vim compiled with a rather

version of Vim. See the other vim-* packages if you need more

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *