How to check a package version before installation in Linux/Ubuntu

Sometimes on Linux Ubuntu/Debian, we want to know in advance what version would we obtain before actually installing a specific package. Using simple tools like aptitude and apt-get makes this very easy to achieve.

Using apt-get

The simulation switch ‘-s’ in the command apt-get allows us to see what would result in case we upgrade or install a given package. The command is as follows :

apt-get -s install <package_name>

As an example, see the snapshot below :

apt-get -s install git

Now replace install with upgrade to see all possible upgrades:

apt-get -V -s upgrade

For instance, for the package, git, this shows :

apt-get -V -s upgrade

Read: How to use the APT command on Ubuntu/Debian Linux systems

Using apt-cache

Using the command apt-cache below will display the installed and the remote version of a package.

apt-cache policy <package>

For the package git, we will see the following information :

apt-cache policy  git

For instance the command related to the package whois will display the following information :

apt-cache policy whois

Note: The numbers 500 (and 100) are called priority numbers. For additional information you can run man apt_preferences in which it is mentioned that 500 corresponds to installable whereas 100 means installed.

Read: Must-do Things After Installing Ubuntu 18.04

Once the package has been installed, you will see both 500 and 100 which correspond to the version that is located in the archives and to the locally installed version respectively.

apt-show-versions

If the package is installed, the command apt-show-versions will show version information about a specific package:

apt-show-versions <package>

In the snapshot below, we installed the command apt-show-versions and then we apply it to sudo command :

 apt-show-versions sudoLinux check package version


If you like the content, we would appreciate your support by buying us a coffe. Thank you so much for your visit and support.

 

ziad nahdy

Ziad Nahdy, fan of open source and programming languages. He is a technical writer, blogger and Linux enthusiast. He loves to read and help others with their problems. He is addicted to open source software but he also loves other technology related subjects.

Leave a Reply

Close Menu