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/jammy-updates,jammy-security,now 7.81.0-1ubuntu1.13 amd64 [installed]
To see all versions of the package available on the repository, pass the -a option.
$ apt list curl -a
Listing... Done
curl/jammy-updates,jammy-security,now 7.81.0-1ubuntu1.13 amd64 [installed]
curl/jammy 7.81.0-1 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.81.0-1ubuntu1.13
Priority: optional
Section: web
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Alessandro Ghedini <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 454 kB
Depends: libc6 (>= 2.34), libcurl4 (= 7.81.0-1ubuntu1.13), zlib1g (>= 1:1.1.4)
Homepage: https://curl.haxx.se
Task: server-minimal, cloud-image, ubuntu-wsl, server, ubuntu-server-raspi, ubuntustudio-publishing, ubuntu-budgie-desktop, ubuntu-budgie-desktop-raspi
Download-Size: 194 kB
APT-Manual-Installed: yes
APT-Sources: https://mirror.hetzner.com/ubuntu/packages jammy-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 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 curl
curl:
Installed: 7.81.0-1ubuntu1.13
Candidate: 7.81.0-1ubuntu1.13
Version table:
*** 7.81.0-1ubuntu1.13 500
500 https://mirror.hetzner.com/ubuntu/packages jammy-updates/main amd64 Packages
500 https://mirror.hetzner.com/ubuntu/security jammy-security/main amd64 Packages
100 /var/lib/dpkg/status
7.81.0-1 500
500 https://mirror.hetzner.com/ubuntu/packages jammy/main amd64 Packages
$ apt-cache policy mariadb-server
mariadb-server:
Installed: (none)
Candidate: 1:10.6.12-0ubuntu0.22.04.1
Version table:
1:10.6.12-0ubuntu0.22.04.1 500
500 https://mirror.hetzner.com/ubuntu/packages jammy-updates/universe amd64 Packages
500 https://mirror.hetzner.com/ubuntu/security jammy-security/universe amd64 Packages
1:10.6.7-2ubuntu1 500
500 https://mirror.hetzner.com/ubuntu/packages jammy/universe amd64 Packages
The first line 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.81.0-1ubuntu1.13 | https://mirror.hetzner.com/ubuntu/packages jammy-updates/main amd64 Packages
curl | 7.81.0-1ubuntu1.13 | https://mirror.hetzner.com/ubuntu/security jammy-security/main amd64 Packages
curl | 7.81.0-1 | https://mirror.hetzner.com/ubuntu/packages jammy/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
p 7.81.0-1 jammy 500
i 7.81.0-1ubuntu1.13 jammy-security,jammy-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/jammy-security 7.81.0-1ubuntu1.13 uptodate
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.81.0-1ubuntu1.13
Enjoy using Ubuntu / Debian Linux is your distribution of choice.
Recommended Linux Books to read:
- Best Linux Books for Beginners & Experts
- Best Linux Kernel Programming Books
- Best Linux Bash Scripting Books
- Top RHCSA / RHCE Certification Study Books
- Best Top Rated CompTIA A+ Certification Books
- Best LPIC-1 and LPIC-2 certification study books