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. Let us see commands to check package version using apt-get command or apt command or aptitude command on a Debian or Ubuntu Linux server.

ADVERTISEMENTS

Method #1: Ubuntu Linux package version 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

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

Method #2: Debian Linux 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

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • niklas Mar 26, 2016 @ 17:10

    i will all linux and gnu begin to windows upp data all have windows 10 can update to debian vs utbuntu vs suse texplar

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.