How to check if an rpm package is installed on a Red Hat Linux server

How to check if an rpm package is installed on a Red Hat Linux server
rpm check, check if package is installed, red hat linux

Maintaining a server up-to-date requires regular rpm checks.

Each time Red Hat releases a newer version of, for example, samba rpm (and requisites) with fixes for known vulnerabilities one needs to check if your server already has that rpm installed and which version, to compare it with the new released one (in the case when you have under administration more servers).

How to check if an rpm package is installed on a Red Hat Linux server

$ rpm -qa | grep samba
samba-common-3.0.9-1.3E.14.1
samba-3.0.9-1.3E.14.1
samba-client-3.0.9-1.3E.14.1

Taking a look at man rpm we’ll se that -q queries and -a queries all packages:

$ man rpm
SYNOPSIS
QUERYING AND VERIFYING PACKAGES:
rpm {-q|–query} [select-options] [query-options]

rpm {-V|–verify} [select-options] [verify-options]

rpm –import PUBKEY …

rpm {-K|–checksig} [–nosignature] [–nodigest]
PACKAGE_FILE …
……………………………………………………..
select-options
[PACKAGE_NAME] [-a,–all] [-f,–file FILE]
[-g,–group GROUP] {-p,–package PACKAGE_FILE]
[–fileid MD5] [–hdrid SHA1] [–pkgid MD5] [–tid TID]
[–querybynumber HDRNUM] [–triggeredby PACKAGE_NAME]
[–whatprovides CAPABILITY] [–whatrequires CAPABILITY]
query-options
[–changelog] [-c,–configfiles] [-d,–docfiles] [–dump]
[–filesbypkg] [-i,–info] [–last] [-l,–list]
[–obsoletes] [–provides] [–qf,–queryformat QUERYFMT]
[-R,–requires] [–scripts] [-s,–state]
[–triggers,–triggerscripts]

The result of the commands shows us that samba rpm and requisites are installed on our server.

You can replace samba with the rpm package you need and play a little with grep and regular expressions to limit the results of the command depending on the desired rpm name.

Leave a Reply

Your email address will not be published. Required fields are marked *