(Last Updated On: June 5, 2018)

I find many people asking a question of How do I check a version of an installed package on my Ubuntu system?, How do I know package versions available on Ubuntu / Debian?. This guide will show you few commands that can be of help. Ubuntu and Debian ship with two main package managers:

  • apt – Manage packages from repositories
  • dpkg  – Manage packages downloaded to the system. Often in .deb format
  • aptitude can be installed

To check for a version of an installed package on your Ubuntu server/desktop, use any of the following methods:

Method 1: Using apt command

The apt command has an option list that you can use to check a version of the package installed on an Ubuntu or Debian system. For example, to check a version of the docker-ce package installed on my Ubuntu 16.04 server, I’d run:

$ apt list docker-ce
Listing... Done
docker-ce/xenial,now 18.03.1~ce-0~ubuntu amd64 [installed]

To see all versions of the package available on the repository, pass the -a option.

$ apt list docker-ce -a
Listing... Done
docker-ce/xenial,now 18.03.1~ce-0~ubuntu amd64 [installed]
docker-ce/xenial 18.03.0~ce-0~ubuntu amd64
docker-ce/xenial 17.12.1~ce-0~ubuntu amd64
docker-ce/xenial 17.12.0~ce-0~ubuntu amd64
docker-ce/xenial 17.09.1~ce-0~ubuntu amd64
docker-ce/xenial 17.09.0~ce-0~ubuntu amd64
docker-ce/xenial 17.06.2~ce-0~ubuntu amd64
docker-ce/xenial 17.06.1~ce-0~ubuntu amd64
docker-ce/xenial 17.06.0~ce-0~ubuntu amd64
docker-ce/xenial 17.03.2~ce-0~ubuntu-xenial amd64
docker-ce/xenial 17.03.1~ce-0~ubuntu-xenial amd64
docker-ce/xenial 17.03.0~ce-0~ubuntu-xenial amd64

The first one the list is currently installed package and all others are available on the repository for installation.

For more details about the package, use the apt show.

$ apt show docker-ce
Package: docker-ce
Version: 18.03.1~ce-0~ubuntu
Priority: optional
Section: admin
Maintainer: Docker <support@docker.com>
Installed-Size: 181 MB
Depends: iptables, init-system-helpers (>= 1.18~), lsb-base (>= 4.1+Debian11ubuntu7), libc6 (>= 2.17), libdevmapper1.02.1 (>= 2:1.02.97), libltdl7 (>= 2.4.6), libseccomp2 (>= 2.3.0), libsystemd0
Recommends: aufs-tools, ca-certificates, cgroupfs-mount | cgroup-lite, git, pigz, xz-utils, apparmor
Conflicts: docker (<< 1.5~), docker-ee, docker-engine, docker-engine-cs, docker.io, lxc-docker, lxc-docker-virtual-package
Replaces: docker-engine
Homepage: https://dockerproject.org
Download-Size: 34.0 MB
APT-Manual-Installed: yes
APT-Sources: https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
Description: Docker: the open-source application container engine
 Docker is an open source project to build, ship and run any application as a
 lightweight container
 .
 Docker containers are both hardware-agnostic and platform-agnostic. This means
 they can run anywhere, from your laptop to the largest EC2 compute instance and
 everything in between - and they don't require you to use a particular
 language, framework or packaging system. That makes them great building blocks
 for deploying and scaling web apps, databases, and backend services without
 depending on a particular stack or provider.

For details about all versions of the docker-ce package, use:

$ apt show docker-ce -a

Method 2: Using apt-cache

apt-cache is a Debian command line tool used to query the APT cache. It provides operations to search and generate interesting output from the package metadata. To search for package version using apt-cache, run:

$ apt-cache policy docker-ce
docker-ce:
  Installed: 18.03.1~ce-0~ubuntu
  Candidate: 18.03.1~ce-0~ubuntu
  Version table:
 *** 18.03.1~ce-0~ubuntu 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
        100 /var/lib/dpkg/status
     18.03.0~ce-0~ubuntu 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.12.1~ce-0~ubuntu 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.12.0~ce-0~ubuntu 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.09.1~ce-0~ubuntu 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.09.0~ce-0~ubuntu 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.06.2~ce-0~ubuntu 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.06.1~ce-0~ubuntu 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.06.0~ce-0~ubuntu 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.03.2~ce-0~ubuntu-xenial 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.03.1~ce-0~ubuntu-xenial 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.03.0~ce-0~ubuntu-xenial 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

The first line show installed version:

Installed: 18.03.1~ce-0~ubuntu --> Show installed version

The other lines give info about other packages available on the repository. Using apt-cache madison will give the same output.

$ apt-cache madison docker-ce
 docker-ce | 18.03.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.12.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.12.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.09.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.09.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.06.2~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.06.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.06.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.03.2~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

Method 3: Using aptitude

Ubuntu doesn’t ship with aptitude, you can install it using:

$ sudo apt-get install aptitude

To check package versions available run:

$ aptitude versions docker-ce
p   17.03.0~ce-0~ubuntu-xenial                      xenial                      500 
p   17.03.1~ce-0~ubuntu-xenial                      xenial                      500 
p   17.03.2~ce-0~ubuntu-xenial                      xenial                      500 
p   17.06.0~ce-0~ubuntu                             xenial                      500 
p   17.06.1~ce-0~ubuntu                             xenial                      500 
p   17.06.2~ce-0~ubuntu                             xenial                      500 
p   17.09.0~ce-0~ubuntu                             xenial                      500 
p   17.09.1~ce-0~ubuntu                             xenial                      500 
p   17.12.0~ce-0~ubuntu                             xenial                      500 
p   17.12.1~ce-0~ubuntu                             xenial                      500 
p   18.03.0~ce-0~ubuntu                             xenial                      500 
i   18.03.1~ce-0~ubuntu                             xenial                      500