How to check package is installed or not in Ubuntu? Here is the command to check version of installed package on Ubuntu – show installed package versions or Ubuntu check package versions available.
3 Commands to Check Version of Installed Package
Learn how to list installed packages with its Ubuntu version.
1. Using apt command
Using apt command with argument list is somewhat similar to dpkg-query –list in that it can display a list of packages satisfying certain criteria. It supports patterns for matching package names as well as options to list installed (–installed), upgradeable (–upgradeable) or all available (–all-versions) versions.
The syntax is:
apt list {package-name-here}
If you wish to see the version of installed firefox package, run the following command:
apt list firefox
2. Using apt-cache Command
apt-cache performs a variety of operations on APT’s package cache. apt-cache does not manipulate the state of the system but does provide operations to search and generate interesting output from the package metadata. The metadata is acquired and updated via the ‘update’ command of e.g. apt-get, so that it can be outdated if the last update is too long ago, but in exchange apt-cache works independently of the availability of the configured sources (e.g. offline).
apt-cache command options to use to check version of installed packages:
- showpkg pkg… : showpkg displays information about the packages listed on the command line. Remaining arguments are package names. The available versions and reverse dependencies of each package listed are listed, as well as forward dependencies for each version.
- policy [pkg…] : policy is meant to help debug issues relating to the preferences file. With no arguments it will print out the priorities of each source. Otherwise it prints out detailed information about the priority selection of the named package.
- madison pkg…: apt-cache’s madison command attempts to mimic the output format and a subset of the functionality of the Debian archive management tool, madison. It displays available versions of a package in a tabular format. Unlike the original madison, it can only display information for the architecture for which APT has retrieved package lists (APT::Architecture).
The syntax is:
apt-cache policy {package}
OR
apt-cache madison {package}
If you wish to see the version of installed firefox package, run the following command:
apt-cache policy firefox
3. Using dpkg Command
dpkg is the package manager for Debian Systems. dpkg is a tool to install, build, remove and manage Debian packages. dpkg maintains some usable information about available packages.
dpkg -s {package-name-here} | grep -i version
If you wish to see the version of installed firefox package, run the following command:
dpkg -s firefox | grep -i version