RPM – Red Hat Package Manager.
RPM is the package manager for Linux system. The ‘rpm’ command is used to install, manage, uninstall packages from server/system. Here I am explaining some common usages of the ‘rpm’ command with example:
1, How to list all packages installed on the server?
# rpm -qa
Example:
[root@localhost]# rpm -qa
xorg-x11-drv-trident-1.3.6-4.el6.x86_64
m17n-contrib-assamese-1.1.10-4.el6_1.1.noarch
wqy-zenhei-fonts-0.9.45-3.el6.noarch
startup-notification-0.10-2.1.el6.x86_64
xml-common-0.6.3-32.el6.noarch
xorg-x11-drv-rendition-4.2.5-2.el6.x86_64
m17n-contrib-hindi-1.1.10-4.el6_1.1.noarch
paktype-tehreer-fonts-2.0-8.el6.noarch
ibus-libs-1.3.4-6.el6.x86_64
mozilla-filesystem-1.9-5.1.el6.x86_64
............
............
2, Find the total number of installed packages ?
[root@localhost]# rpm -qa|wc -l
1094
3, How to find a package is installed or not ?
# rpm -qa|grep -i "package-name"
Example:
[root@localhost]# rpm -qa|grep -i mozilla
mozilla-filesystem-1.9-5.1.el6.x86_64
4, Find all the information regarding the package ?
# rpm -qi package-name
Example:
[root@localhost]# rpm -qi mozilla-filesystem-1.9-5.1.el6.x86_64
Name        : mozilla-filesystem           Relocations: (not relocatable)
Version     : 1.9                               Vendor: CentOS
Release     : 5.1.el6                       Build Date: Wed 18 Aug 2010 09:14:21 PM IST
Install Date: Thu 28 Mar 2013 01:37:47 PM IST      Build Host: c6b3.bsys.dev.centos.org
Group       : Applications/Internet         Source RPM: mozilla-filesystem-1.9-5.1.el6.src.rpm
Size        : 0                                License: MPLv1.1
Signature   : RSA/8, Sun 03 Jul 2011 10:15:46 AM IST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Summary     : Mozilla filesytem layout
Description :
This package provides some directories required by packages which use
Mozilla technologies such as NPAPI plugins or toolkit extensions.
5, How to find the parent package details of a command ?
Example: To fing the package name of the ‘ls’ command.
# rpm -qf /path/to/command
Example:
[root@localhost]# which ls
alias ls='ls --color=auto'
 /bin/ls
----
[root@localhost]# rpm -qf /bin/ls
coreutils-8.4-19.el6.x86_64
6, How to list all commands or contens from a package ?
# rpm -ql package-name
Example:
[root@localhost TAR]# rpm -ql coreutils-8.4-19.el6.x86_64
/bin/arch
/bin/basename
/bin/cat
/bin/chgrp
/bin/chmod
/bin/chown
/bin/cp
/bin/cut
/bin/date
/bin/dd
/bin/df
/bin/echo
.........
.........
.........
7, How to install a package using rpm command ?
The rpm command with ‘-i’ switch is used to install a package on server.
Syntax:
# rpm -ivh package-name
Where;
-i : install a package
-v : verbose
-h : print hash marks as the package archive is unpacked.
Example:
# rpm -ivh  MySQL-client-3.23.57-1.i386.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
8, How to upgrade a package using rpm command ?
You can upgrade the already installed package by using the switch ‘-U’
Syntax:
# rpm -Uvh package-name
Example:
# rpm -Uvh MySQL-client-3.23.57-1.i386.rpm
Preparing...    ########################################### [100%]
1:MySQL-client          ################################################### [100%]

9, How to remove a package using rpm command ? Use the switch ‘-e’ to erase package from server. Syntax:
# rpm -ev package-name
10, Verify a Package Owning file using rpm -Vf
The following command verify the package which owns the given filename.
# rpm -Vf /usr/bin/mysqlaccess
S.5....T c /usr/bin/mysql
#
11, Find out the state of files in a package using rpm -qsp
The three states are:
installed 
replaced 
normal
The following command is to find state for all the files in a RPM package.
# rpm -qsp MySQL-client-3.23.57-1.i386.rpm
normal        /usr/bin/msql2mysql
normal        /usr/bin/mysql
normal        /usr/bin/mysql_find_rows
normal        /usr/bin/mysqlaccess
normal        /usr/bin/mysqladmin
normal        /usr/bin/mysqlbinlog
normal        /usr/bin/mysqlcheck
...........
...........
12, List the Dependency of Packages.
To view the list of packages on which this package depends, use -qRP with rpm command.
Example:
# rpm -qRp MySQL-client-3.23.57-1.i386.rpm
/bin/sh
/usr/bin/perl
13, –nodeps
This switch along with rpm command will install the package forcefully by avoiding its dependencies.
Other useful commands:
groupdelgroupmemsgroupmoduseradd usermod chgrpchownlsheadtailtopps,findcrontabftp commandstar