How to check if a specific software version is installed in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to check the version of installed software in Linux using different methods. You will start by using the common --version option supported by many command-line programs to quickly display their versions.

Next, you will explore how to use the apt show command, a powerful tool on Debian-based systems, to retrieve detailed information about installed packages, including their versions. Finally, you will learn how to verify installed software versions using the dpkg -l command, which lists installed packages and their versions. These techniques are essential for troubleshooting, ensuring compatibility, and managing software on your Linux system.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/TextProcessingGroup(["Text Processing"]) linux(("Linux")) -.-> linux/PackagesandSoftwaresGroup(["Packages and Softwares"]) linux(("Linux")) -.-> linux/VersionControlandTextEditorsGroup(["Version Control and Text Editors"]) linux/TextProcessingGroup -.-> linux/grep("Pattern Searching") linux/PackagesandSoftwaresGroup -.-> linux/curl("URL Data Transferring") linux/PackagesandSoftwaresGroup -.-> linux/apt("Package Handling") linux/PackagesandSoftwaresGroup -.-> linux/software("Linux Software") linux/VersionControlandTextEditorsGroup -.-> linux/nano("Simple Text Editing") subgraph Lab Skills linux/grep -.-> lab-558764{{"How to check if a specific software version is installed in Linux"}} linux/curl -.-> lab-558764{{"How to check if a specific software version is installed in Linux"}} linux/apt -.-> lab-558764{{"How to check if a specific software version is installed in Linux"}} linux/software -.-> lab-558764{{"How to check if a specific software version is installed in Linux"}} linux/nano -.-> lab-558764{{"How to check if a specific software version is installed in Linux"}} end

Display version with software --version

In this step, you'll learn a common way to check the version of installed software in Linux using the --version option. Many command-line programs support this option to display their version information.

Let's try it with a few common commands you might encounter.

First, let's check the version of the bash shell. Type the following command in your terminal and press Enter:

bash --version

You should see output similar to this, showing the version of bash installed on the system:

GNU bash, version 5.1.16(1)-release (...)
...

Next, let's check the version of the nano text editor, which is often used in the terminal. Type:

nano --version

The output will show the nano version:

GNU nano, version 5.9
...

Finally, let's check the version of the curl command, a tool for transferring data with URLs. Type:

curl --version

You'll see output listing the curl version and supported protocols:

curl 7.81.0 (...)
...

Using --version is a quick and easy way to find out which version of a specific command-line tool you are using. This is often helpful for troubleshooting or ensuring compatibility.

Click Continue to proceed.

Check package version with apt show

In the previous step, you learned how to check the version of a command using the --version flag. However, this only works if the command itself supports it. A more general way to get detailed information about installed software, including its version, is by using the package manager.

On Debian-based systems like Ubuntu, the apt command is used for package management. The apt show command can display information about a specific package.

Let's use apt show to check the version of the nano package. Type the following command in your terminal and press Enter:

apt show nano

You will see a lot of information about the nano package. Look for the line that starts with Version:.

Package: nano
Version: 5.9-4
...
APT-Sources: http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
Description: small, friendly text editor inspired by Pico
...

The output shows the package name, its version, dependencies, description, and other details. This is a powerful way to get comprehensive information about installed software packages.

Now, let's try checking the information for the curl package:

apt show curl

Again, look for the Version: line in the output.

Package: curl
Version: 7.81.0-1ubuntu1.10
...
APT-Sources: http://security.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
Description: command line tool for transferring data with URL syntax
...

Using apt show is particularly useful when you need more details than just the version number, such as the package's dependencies or where it was installed from.

Click Continue to move to the next step.

Verify installed version with dpkg -l

In this step, you will learn another command to verify the installation and version of packages on your system: dpkg. The dpkg command is the low-level tool for managing Debian packages, and apt uses dpkg behind the scenes.

The dpkg -l command lists all installed packages. This can produce a very long output, so it's common to pipe the output to grep to filter for a specific package.

Let's use dpkg -l to check if the nano package is installed and see its version. Type the following command in your terminal and press Enter:

dpkg -l nano

The output will show a line for the nano package if it's installed. The second column shows the version.

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/Trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||| Name           Version      Architecture Description
+++-==============-============-============-============================================
ii  nano           5.9-4        amd64        small, friendly text editor inspired by Pico

In this output:

  • ii in the first two columns indicates that the package is installed (i) and its configuration files are installed (i).
  • nano is the package name.
  • 5.9-4 is the installed version.

Now, let's check the curl package using the same command:

dpkg -l curl

You should see similar output for the curl package:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/Trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||| Name           Version      Architecture Description
+++-==============-============-============-============================================
ii  curl           7.81.0-1ubuntu1.10 amd64        command line tool for transferring data with URL syntax

The dpkg -l command is a fundamental tool for verifying the presence and version of installed packages on Debian-based systems.

Click Continue to complete this lab.

Summary

In this lab, you learned how to check the version of installed software in Linux using different methods. You first explored the common practice of using the --version option with various command-line tools like bash, nano, and curl to quickly display their versions. This method is straightforward but depends on the software supporting the option.

Subsequently, you discovered a more comprehensive approach using the apt package manager on Debian-based systems. By utilizing the apt show command with a package name like nano, you can retrieve detailed information about the installed package, including its version, which is a more general method for verifying software versions.