It is more often than not that we need to check the existence of a particular package after the installation of the operating system. There are many instances where an old version of a package needs to be removed or upgrade. This section explains in a nutshell how to administer the package management with the use of RPM.

RPM stands for Red Hat Package Manager. It is a program designed to build and manage packages of software distributed in both source and binary format. It is portable and can be run on different platforms. RPM files with the extension .rpm typically include the compiled programs and libraries required for the package and associated documentation, scripts to install, verify, and uninstall, and also cryptographic signatures for each file in the package. This architecture makes it very easy to verify the integrity of the package. Each RPM also includes a list of packages that it depends on, and a list of services that are provided by the package.

RPM maintains a database of all installed packages in /var/lib/rpm/. Included in the database is a list of all files installed by RPM and which package they belong to. This makes it a very powerful tool for finding out more information about each package and where the files are installed. Sources are often provided in source RPMs (*.src.rpm or *.spm). These sources include the developer source code, any patches applied by the package builder, and a SPEC file that is used to tell rpm how to compile the package.

You have to logged in as user root to install, upgrade, or remove packages. However, you can run queries as any user. The RPM package format has been adopted by many major Linux distributions besides Red Hat, such as CentOS and SuSE.

Install and Upgrade commands
rpm -ivh package Install a package (i=install v=verbose h=show hash marks).
rpm -e package Uninstall (erase) a package.
rpm -Uvh package Upgrade a package.
rpm -Uvh --test package Test a package to see how it would install (without installing, also checks dependencies).



Verify commands
rpm -Vvv package Verify a package (extra verbose output).
rpm -Va Verify all installed packages on the system.
rpm -K package Verify the cryptographic signature of a package.
Query commands
rpm -qa Show all installed packages.
rpm -ql package Show files included in the specified package.
rpm -qi package Show general information of a package.
rpm -qf file Show packages owning this file.
rpm -qc package Show configuration files in a package.
rpm -qd package Show documentation files in a package.
rpm -q --scripts package Show scripts in a package.
rpm -q --provides package Show services provided by the package.
rpm -q --requires package Show services required by this package.
rpm -qpl package The above commands query a package that has already been installed. To query a package that has not been installed yet, add the -p option to the command.

You can use grep to search for the complete name of a particular package as following
rpm -qa | sort | grep

The following command counts the total number of packages installed:
rpm -qa | grep "." -c