In Linux/Unix system root user can use RPM command is used to install, uninstall, upgrade, query, verify, checking etc RPM packages in Linux/Unix systems.

RPM stand for RedHat Package Manager is package management system is used to install, installant, upgrade, query, verify, checking etc RPM packages in Linux/Unix systems.

RPM package contain an arbitrary set of files. RPM refers to .rpm file format. RPM file are of two types. One is “binary RPMs” (or BRPMs) contain complied version of software. Second type is “Source RPMs” contain source code used to create package.

In this Post, we would try to check various RPM commands that could use in Linux day to day administrative work.

1. Installing RPM Packages

Most important task for RPM command is to install RPM packages on Linux system. For installing RPM packages through ” rpm -ivh Package-path “.

[root@srv103 ~]# if [ -z `rpm -qa vsftpd` ]; then echo “vsftpd package is not installed” ; else echo “vsftpd package is installed”; fi
vsftpd package is not installed
[root@srv103 ~]# rpm -ivh /var/ftp/pub/Packages/vsftpd-2.2.2-11.el6_4.1.x86_64.rpm
warning: /var/ftp/pub/Packages/vsftpd-2.2.2-11.el6_4.1.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing… ########################################### [100%]
1:vsftpd ########################################### [100%]
[root@srv103 ~]# if [ -z `rpm -qa vsftpd` ]; then echo “vsftpd package is not installed” ; else echo “vsftpd package is installed”; fi
vsftpd package is installed

In above box, we can see vsftpd package was not installed. We have installed it with RPM command with ” rpm -ivh Package-path “. Further we have tried to to check vsftpd package in system and now it is installed.

rpm command’s options
    install a package
    Print lots of ugly debugging information.
    print hash marks as the package archive is unpacked.

2. Installing a RPM Package with Unresolved Dependency using rpm -ivh –nodesp

RPM packages have some dependencies, which should resolved (installed) before package installatin. But sometime we like to install packages without installations dependencies.

#rpm -ivh –nodeps

3. Upgrading RPM Packages using rpm -Uvh

Upgrade RPM package from old one which were already installed.So upgrade option uninstall pervious package and install new one, in case no package install then it simple install package.

rpm -Uvh foo-1.0-1.i386.rpm


In case upgrading kernel version, never use -Uvh. Safe to use -ivh (install) and then change kernel version from kernel configuration file

4. Query RPM Packages

RPM command can use to query for all RPM installed in Linux/unix System.

# rpm -qa

With above examples we can see ” rpm -qa “ command will show all RPM installed on system. You can also query for specfic RPMs as well with same command ” rpm -q Package-path “.

Query for single RPM
# rpm -q vsftpd

Query for multiple RPMs
# rpm -q zip audit setup java
package java is not installed

Find out string from all RPMs
# rpm -qa|grep java

rpm command’s options

5. Which RPM package does a file belong to? – Use rpm -qf

Sometime we need to know package which owns files present in file-system. This will provide package name through which we can further try to find out package details.

# rpm -qf /etc/inittab

6. Information about Installed RPM Package using rpm -qi

Sometime we need to know information about some packages which are already installed on system. In Below image we can see there is information about installed package.

[root@srv103 ~]# rpm -qi initscripts-9.03.40-2.el6.centos.x86_64
Name        : initscripts                  Relocations: (not relocatable)
Version     : 9.03.40                           Vendor: CentOS
Release     : 2.el6.centos                  Build Date: Fri 22 Nov 2013 04:20:27 PM EST
Install Date: Mon 14 Dec 2015 04:40:54 AM EST      Build Host:
Group       : System Environment/Base       Source RPM: initscripts-9.03.40-2.el6.centos.src.rpm
Size        : 5719607                          License: GPLv2 and GPLv2+
Signature   : RSA/SHA1, Sun 24 Nov 2013 02:31:43 PM EST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem 
URL         :
Summary     : The inittab file and the /etc/init.d scripts
Description :
The initscripts package contains the basic system scripts used to boot
your Red Hat, CentOS or Fedora system, change runlevels, and shut the
system down cleanly.  Initscripts also contains the scripts that activate
and deactivate most network interfaces.

Sometime we need to know package information for packages located on remotely or on file system. In below images, tried to cover both examples.

[root@srv103 ~]# rpm -qip
Name        : vsftpd                       Relocations: (not relocatable)
Version     : 2.2.2                             Vendor: CentOS
Release     : 11.el6_4.1                    Build Date: Fri 01 Mar 2013 05:16:39 AM EST
Install Date: (not installed)               Build Host:
Group       : System Environment/Daemons    Source RPM: vsftpd-2.2.2-11.el6_4.1.src.rpm
Size        : 339348                           License: GPLv2 with exceptions
Signature   : RSA/SHA1, Fri 01 Mar 2013 05:21:13 AM EST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem 
URL         :
Summary     : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from

rpm command’s options
    Display package information, including name, version, and description.
    List capabilities this package provides.

7. Which files does a package belong to? – Use rpm -ql

Sometime we like to know list of files does package belongs to. We can query list of files for packages installed or uninstalled packages (locally or remotely located)

# rpm -qlp
rpm -ql vsftpd

rpm command’s options
    List files in package.

8. Query for doc file or configuration file? – Use rpm -qc or rpm -qd

Sometime we like to know list of configuration files or documentation file for package file, this package could be installed or uninstalled remotely or locally located package file.

#rpm -qc vsftpd
#rpm -qd vsftpd
#rpm -qcp /var/ftp/pub/Packages/vsftpd-2.2.2-11.el6_4.1.x86_64.rpm
#rpm -qdp /var/ftp/pub/Packages/vsftpd-2.2.2-11.el6_4.1.x86_64.rpm

rpm command’s options
    List only configuration files.
    List only documentation files.

9. Find out the state of files in a package using rpm -qs

Display the states of files in the package.The state of each file is one of normal, not installed, or replaced.

# rpm -qs openssh-server
normal /etc/pam.d/ssh-keycat
normal /etc/pam.d/sshd
normal /etc/rc.d/init.d/sshd
normal /etc/ssh/sshd_config
normal /etc/sysconfig/sshd
normal /usr/libexec/openssh/sftp-server
normal /usr/libexec/openssh/ssh-keycat
normal /usr/sbin/.sshd.hmac
normal /usr/sbin/sshd

10. Verifying all the RPM Packages using rpm -V

Sometime we like to Verify information about the installed files in the package with information about the files taken from the package metadata stored in the rpm database. Among other things, verifying compares the size, digest, permissions, type, owner and group of each file.
we can verify individual packages or all packages installed on system. In below output tried to cover this in both secnrio.

# rpm -qV openssh-server
S.5….T. c /etc/ssh/sshd_config

# rpm -Va
S.5….T. c /etc/ssh/sshd_config
S.5….T. c /etc/maven/maven2-depmap.xml
..5….T. c /usr/lib64/security/
….L…. c /etc/pam.d/fingerprint-auth
….L…. c /etc/pam.d/password-auth
….L…. c /etc/pam.d/smartcard-auth
….L…. c /etc/pam.d/system-auth
missing c /etc/yum.repos.d/CentOS-Base.repo
missing c /etc/yum.repos.d/CentOS-Debuginfo.repo
missing c /etc/yum.repos.d/CentOS-Media.repo
missing c /etc/yum.repos.d/CentOS-Vault.repo
…….T. c /etc/inittab

The format of the output is a string of 8 characters, a possible attribute marker.

c %config configuration file.
d %doc documentation file.
g %ghost file (i.e. the file contents are not included in the package payload).
l %license license file.
r %readme readme file.

From the package header, followed by the file name.Each of the 8 characters denotes the result of a comparison of attribute(s) of the file to the value of those attribute(s) recorded in the database.A single “.” (period) means the test passed, while a single “?” (question mark) indicates the test could not be performed (e.g. file permissions pre-vent reading).Otherwise, the (mnemonically emBoldened) character denotes failure of the corresponding –verify test.

    file Size differs
    Mode differs (includes permissions and file type)
    digest (formerly MD5 sum) differs
    Device major/minor number mismatch
    readLink(2) path mismatch
    User ownership differs
    Group ownership differs
    mTime differs
    caPabilities differ

we can verify same direct from file as well and further identify packages and verify all files provided by that package, Below example tried to cover two case. One that have difference while other have no difference.

[root@srv103 ~]# rpm -Vf /etc/fstab
[root@srv103 ~]# rpm -qf /etc/fstab
[root@srv103 ~]# rpm -qV setup-2.8.14-20.el6_4.1.noarch

[root@srv103 ~]# rpm -Vf /etc/ssh/sshd_config
S.5….T. c /etc/ssh/sshd_config
[root@srv103 ~]# rpm -qf /etc/ssh/sshd_config
[root@srv103 ~]# rpm -qV openssh-server-5.3p1-94.el6.x86_64
S.5….T. c /etc/ssh/sshd_config

11. Uninstalling a RPM Package using rpm -e

sometime we like to uninstall RPM packages that already installed on Linux system. See below image which contain example for uninstallation of RPM package from Linux system.

12. Freshening the RPM Packages using rpm -F

Freshening the RPM Packages is same as upgrade except it only upgarde in case package is already installed on system. it checks package installed against the package provided in command line, only in case provided package is new then it will install. But if no package is installed then freshening will not do anything.

rpm -Fvh foo-1.2-1.el6.x86_64.rpm

13. Dump file contain in RPM Package using rpm -q –dump

Sometime we like to get detail information about the files taken from the package metadata stored in the rpm database. This could provide ” path size mtime digest mode owner group isconfig isdoc rdev symlink “.

# rpm -q –dump libgcc
/lib64/ 90880 1385057326 18541661133eebafb1266afdc009085bb2e9125813d9e2d495a3fca6f23725ee 0100755 root root 0 0 0 X
/lib64/ 28 1385057297 0000000000000000000000000000000000000000000000000000000000000000 0120777 root root 0 0 0
/usr/share/doc/libgcc-4.4.7 4096 1385063223 0000000000000000000000000000000000000000000000000000000000000000 040755 root root 0 0 0 X
/usr/share/doc/libgcc-4.4.7/COPYING.LIB 26440 1231931189 32434afcc8666ba060e111d715bfdb6c2d5dd8a35fa4d3ab8ad67d8f850d2f2b 0100644 root root 0 1 0 X

14. Know capabilities on which this package depends rpm -qR

Before installation RPM Packages its dependencies should need to install on system. we can find out Packages dependencies easily with command.
Below command would easily explain libgcc dependencies on which package depends.

[root@srv103 ~]# rpm -qR libgcc

rpmlib(VersionedDependencies) <= 3.0.3-1
rpmlib(BuiltinLuaScripts) <= 4.2.2-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadIsXz) <= 5.2-1

15. List package specific scriptlet of the installation and uninstallation processes rpm -q –scripts

This could help to find out package installation and uninstallation process in details. This could helps to make further understanding in package functions in case of any troubleshooting, please see below image for explanation.