We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Check version of Installed Package on Ubuntu / Debian

Learn how to – Check version of Installed Package on Ubuntu / Debian.

I find many people asking a question “how do I check a version of an installed package on my Ubuntu/Debian system?, How do I know package versions available on Ubuntu / Debian Linux operating system?. In Linux, all applications are distributed as packages, which are nothing more than files associated with a package management system. This guide will show you few commands which can be used to check the version of a Package on Ubuntu / Debian Linux machine.

Debian based Linux systems 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 and used in similar manner to apt

To check for a version of an installed package on your Ubuntu server/desktop, use any of the methods shown in next sections.

Before you get started update your package APT index:

sudo apt update

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 curl package installed on my Ubuntu/Debian server, I’d run:

$ apt list curl
Listing... Done
curl/focal-updates,focal-security,now 7.68.0-1ubuntu2.2 amd64 [installed,automatic]
N: There is 1 additional version. Please use the '-a' switch to see it

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

$ apt list curl -a
Listing... Done
curl/focal-updates,focal-security 7.68.0-1ubuntu2.5 amd64 [upgradable from: 7.68.0-1ubuntu2.2]
curl/now 7.68.0-1ubuntu2.2 amd64 [installed,upgradable to: 7.68.0-1ubuntu2.5]
curl/focal 7.68.0-1ubuntu2 amd64

This includes all others packages available on the repository for installation.

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

$ apt show curl
Package: curl
Version: 7.68.0-1ubuntu2.5
Priority: optional
Section: web
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Alessandro Ghedini <ghedo@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 411 kB
Depends: libc6 (>= 2.17), libcurl4 (= 7.68.0-1ubuntu2.5), zlib1g (>= 1:1.1.4)
Homepage: http://curl.haxx.se
Task: server, cloud-image, ubuntu-budgie-desktop
Download-Size: 161 kB
APT-Sources: http://mirrors.digitalocean.com/ubuntu focal-updates/main amd64 Packages
Description: command line tool for transferring data with URL syntax
 curl is a command line tool for transferring data with URL syntax, supporting
 DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3,
 POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP.
 .
 curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form
 based upload, proxies, cookies, user+password authentication (Basic, Digest,
 NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a
 busload of other useful tricks.

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

$ apt show curl -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 curl
curl:
  Installed: 7.68.0-1ubuntu2.2
  Candidate: 7.68.0-1ubuntu2.5
  Version table:
     7.68.0-1ubuntu2.5 500
        500 http://mirrors.digitalocean.com/ubuntu focal-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
 *** 7.68.0-1ubuntu2.2 100
        100 /var/lib/dpkg/status
     7.68.0-1ubuntu2 500
        500 http://mirrors.digitalocean.com/ubuntu focal/main amd64 Packages

$ apt-cache policy mariadb-server
mariadb-server:
  Installed: (none)
  Candidate: 1:10.3.29-0ubuntu0.20.04.1
  Version table:
     1:10.3.29-0ubuntu0.20.04.1 500
        500 http://mirrors.digitalocean.com/ubuntu focal-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
     1:10.3.22-1ubuntu1 500
        500 http://mirrors.digitalocean.com/ubuntu focal/universe amd64 Packages

The first line show installed version:

Installed: 7.68.0-1ubuntu2.2 --> Show installed version

If the package is not installed you’ll see none as value of Installed key:

  Installed: (none)

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

$ apt-cache madison curl
      curl | 7.68.0-1ubuntu2.5 | http://mirrors.digitalocean.com/ubuntu focal-updates/main amd64 Packages
      curl | 7.68.0-1ubuntu2.5 | http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
      curl | 7.68.0-1ubuntu2 | http://mirrors.digitalocean.com/ubuntu focal/main amd64 Packages

Method 3: Using aptitude

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

sudo apt update
sudo apt install aptitude -y

To check package versions available run:

$ aptitude versions curl
aptitude versions curl
p A 7.68.0-1ubuntu2                                                                        focal                                                              500
i A 7.68.0-1ubuntu2.2                                                                                                                                         100
p A 7.68.0-1ubuntu2.5                                                                      focal-security,focal-updates                                       500

Method 4: Using apt-show-versions

The apt-show-versions command is used to list available package versions with distribution. Install the package:

sudo apt update
sudo apt install apt-show-versions -y

Use the command to query installed package versions:

$ apt-show-versions curl
curl:amd64/focal-security 7.68.0-1ubuntu2.2 upgradeable to 7.68.0-1ubuntu2.5

Output for a package not installed in the system:

$ apt-show-versions mariadb-server
mariadb-server:all not installed

Dpkg command with grep filter can show the version of package installed:

$ dpkg -s curl | grep Version
Version: 7.68.0-1ubuntu2.2

Enjoy using Ubuntu / Debian Linux is your distribution of choice.

Linux Learning courses:

Below are some learning courses we recommend:

Linux Mastery: Master the Linux Command Line in 11.5 Hours

Linux Administration Bootcamp: Go from Beginner to Advanced

Complete Linux Training Course to Get Your Dream IT Job 2021

Cart

Your Cart is Empty

Back To Shop