How to Check the Package Version Using apt-get/aptitude?

The “aptitude” is a high-level package manager that provides an interactive text-based user interface to perform package management tasks. It also offers the functionality apt-mark and apt-cache for searching the installed package, marking a package for automatic and manual installation, and so on.

On the other hand, the “apt-get” is a low-level package manager restricted to the command line

The main objective of both these utilities is to perform the tasks such as installing, removing, updating, and checking the version of installed packages. The package version requires checking whether the package needs to be updated or not to keep the system up to date.

This post illustrates how to check the package version:

  • Using aptitude Command
  • Using apt-get Command

Method 1: aptitude Command to Check the Package Version

The “aptitude” is another command line tool that helps in the installation, removal, updation and upgradation of the packages in the Ubuntu or Debian-based operating system. It is similar to the “apt-get” command.

To check the version of the installed packages, follow the below syntax: 

Syntax:

$ aptitude versions [package name]

According to this syntax, the “version” flag of the “aptitude” command prints the specific installed package version.

Example:

The package “curl” version is again checked using the “aptitude” command:

$ sudo aptitude versions curl

The output shows all the available installed versions of the “curl” command line tool.

This task can also be performed using the “aptitude” command followed by the “-s(simulation)” and the “-V(verbose)” flag like this:

$ aptitude -V -s install curl

The output shows the version of the installed “curl” package.

Method 2: apt-get Command to Check the Package Version

The “apt-get” is an older package manager of the core APT (Advanced Package Tools). It is used to install, remove, update, and upgrade the system packages. It gets information about the packages from official repositories or authenticated sources.

In addition, it also helps check the system’s installed package versions via the syntax below:

Syntax:

$ apt-get -s install [package name]

The above-generalized syntax is illustrated here:

  • apt-get: Represents the main “apt-get” command utility.
  • -s: Means “Simulation,” i.e., the dry run of the event and does not perform any operation.
  • install: Specifies the “install” command for installing or upgrading new packages.
  • package name: Displays the package name whose version needs to be checked.

Example: Check Package Version

For instance, the installed “curl” package version is checked using the “apt-get” command:

$ sudo apt-get -s install curl

The installed “curl” package version is “7.81.0”.

Upgrade the Package:

To see all the upgrades of the particular packages such as “curl,” run the “apt-get” command followed by “-V(verbose)” and “upgrade” utility:

$ sudo apt-get -V upgrade curl

Enter the “Y” for yes to continue the upgradation of all the mentioned packages for the “curl” command line tool.

Method 3: Using aptitude Command to Check the Package Version

The “aptitude” is another command line tool that helps install, remove, update, and upgradation of packages in the Debian-based operating system. It is similar to the “apt-get” command.

To check the version of the installed packages, follow the below syntax: 

Syntax:

$ aptitude versions [package name]

According to this syntax, the “version” flag of the “aptitude” command prints the specific installed package version.

Example:

The package “curl” version is again checked using the “aptitude” command:

$ sudo aptitude versions curl

The output shows all the available installed versions of the “curl” command line tool.

This task can also be performed using the “aptitude” command followed by the “-s(simulation)” and the “-V(verbose)” flag like this:

$ aptitude -V -s install curl

The output shows the version of the installed “curl” package.

Conclusion

The “apt-get” command uses the “-s(simulation)” flag to check the “install” package version. On the other hand, the “aptitude” supports the “version” flag to perform this task. Although both commands are useful, however, the use of aptitude is recommended because of its better functionality as compared to “apt-get.”

This guide post has briefly described how to check the package version using “apt-get” and “aptitude.”