Linux – How to find what version of a package is installed

By | 2012/06/08

Below are commands to verify the exact version of a package installed in Linux. Root prompt or sudo is not required!


Red Hat or CentOS:

$ rpm -qa | grep package

Example:

$ rpm -qa | grep openssl
openssl-1.0.0-20.el6_2.5.x86_64

If a package is not installed, the output will return nothing:

$ rpm -qa | grep firefox
$


Ubuntu or Debian:

$ dpkg -s package

Example:

$ dpkg -s openssl
Package: openssl
Status: install ok installed
Priority: optional
Section: utils
Installed-Size: 844
Maintainer: Ubuntu Developers 
Architecture: i386
Version: 0.9.8k-7ubuntu8.13
Depends: libc6 (>= 2.7), libssl0.9.8 (>= 0.9.8k-1), zlib1g (>= 1:1.1.4)
Suggests: ca-certificates, openssl-doc
Conflicts: ssleay (<< 0.9.2b)
Conffiles:
 /etc/ssl/openssl.cnf 0b1cf9a835b829131d630b7c2fe55f3c
Description: Secure Socket Layer (SSL) binary and related cryptographic tools
 This package contains the openssl binary and related tools.
 .
 It is part of the OpenSSL implementation of SSL.
 .
 You need it to perform certain cryptographic actions like:
  -  Creation of RSA, DH and DSA key parameters;
  -  Creation of X.509 certificates, CSRs and CRLs;
  -  Calculation of message digests;
  -  Encryption and decryption with ciphers;
  -  SSL/TLS client and server tests;
  -  Handling of S/MIME signed or encrypted mail.
Original-Maintainer: Debian OpenSSL Team 

If a package is not installed, the output will look similar to:

$ dpkg -s firefox
Package `firefox' is not installed and no info is available.
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.

Cool!