Linux Administrator

RPM Package Manager Command Examples

rpm
mm
Written by Santosh Prasad

RPM (Red Hat Package Manager) is the most popular package manager tool for Red Hat based system such as RHEL, CentOS and Fedora. This tool allows Linux users to install, uninstall, update, verify, query and manage software packages. It is default package manager for RedHat Linux system.

RPM is a file which include uninstallable software and libraries need by the package. It is free tool created by RedHat. RPM stores all information about packages in “/var/lib/rpm” database.

RPM Advantages

1. Easy to install and uninstall program
2. Automatic Installation
3. Easy to update installed software
4. It is available for all Linux distributions

Basic RPM Command Option

  • Install : Used to install RPM package.
  • Remove : Used to remove, erase and uninstall RPM package.
  • Upgrade : Used to upgrade the existing RPM package.
  • Verify : Used to query about different RPM package.
  • Query : Used to verify the RPM package.

RPM Command Examples

Install Package

Follow the below command to install .rpm package. Make sure you are logged as a root user to run this command.

# rpm -ivh  MySQL-client-3.23.57-1.i386.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]

Where,
i : Used for install package
v : In verbose mode
h : Used for human readable format

Query All RPM Packages

Type the below command to query all the installed rpm packages on the system.

# rpm -qa 
 
libertas-usb8388-firmware-5.110.22.p23-3.1.el6.noarch
libjpeg-6b-46.el6.x86_64
perl-XML-NamespaceSupport-1.10-3.el6.noarch
libacl-2.2.49-4.el6.x86_64
checkpolicy-2.0.22-1.el6.x86_64
psa-atis-1.1-50.x86_64
tomcat6-6.0.24-33.el6.noarch
.....................
.............
..........

Where,
q : For query operation
a : For all installed package

Query Only For Particular RPM Package

To query for particular rpm package you can use grep command as shown below:

# rpm -qa | grep "procmail"
procmail-3.22-25.1.el6.x86_64
OR
# rpm -q procmail
procmail-3.22-25.1.el6.x86_64

Note :- For “rpm -q procmail” command you have to specify the exact package name, otherwise command will report that the package is not installed.

Query RPM Package In Various Format

You can also get the various format such as header tag name using -queryformat option.

# rpm -qa --queryformat '%{name}-%{version}-%{release} %{size}\n'
libertas-usb8388-firmware-5.110.22.p23-3.1.el6 129601
libjpeg-6b-46.el6 300249
perl-XML-NamespaceSupport-1.10-3.el6 28882
libacl-2.2.49-4.el6 31856
checkpolicy-2.0.22-1.el6 870239
psa-atis-1.1-50 134903
tomcat6-6.0.24-33.el6 195128
keyutils-libs-1.4-1.el6 33820
busybox-1.15.1-11.el6 1120107
......................
..................
............

Which RPM Package Does a File Belongs To?

Using –qf option with rpm command, lets say if you have a file and would want to know which package owns all these files.

# rpm -qf /usr/bin/mysqlaccess
mysql-5.5.36-21.el6.art.x86_64

Where,

f : For file name

Get All Information About Installed RPM Package

You can get all information about installed rpm package using rpm -qi options as shown below:

# rpm -qi mysql
Name        : mysql                        Relocations: (not relocatable)
Version     : 5.5.36                            Vendor: (none)
Release     : 21.el6.art                    Build Date: Tue 11 Feb 2014 07:19:53 AM CST
Install Date: Thu 20 Feb 2014 03:37:19 AM CST      Build Host: loggerhead.atomicorp.com
Group       : Applications/Databases        Source RPM: mysql-5.5.36-21.el6.art.src.rpm
Size        : 30006357                         License: GPLv2 with exceptions
Signature   : DSA/SHA1, Tue 11 Feb 2014 07:50:28 AM CST, Key ID 32a951145ebd2744
URL         : http://www.mysql.com
Summary     : MySQL client programs and shared libraries
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. The base package
contains the standard MySQL client programs and generic MySQL files.

If you want to know more information about rpm package before installing you can type below command:

# rpm -qip MySQL-client-3.23.57-1.i386.rpm
Name        : MySQL-client                 Relocations: (not relocatable)
Version     : 3.23.57                           Vendor: MySQL AB
Release     : 1                             Build Date: Mon 09 Jun 2003 11:08:28 PM CEST
Install Date: (not installed)               Build Host: build.mysql.com
Group       : Applications/Databases        Source RPM: MySQL-3.23.57-1.src.rpm
Size        : 5305109                          License: GPL / LGPL
Signature   : (none)
Packager    : Lenz Grimmer
URL         : http://www.mysql.com/
Summary     : MySQL - Client
Description : This package contains the standard MySQL clients.

Where,
i : Get information about rpm
p : Provide the package name

Listing All The File Related To RPM Package

You can also list all the content of a rpm package, using below command:

# rpm -qlp procmail-3.22-25.1.el6.x86_64.rpm

/usr/bin/procmail
/usr/bin/procmaildb
/usr/bin/procmailprm
.
.
/usr/bin/procmailusr

Where,
q : Used for query the rpm file
l : Used for list files in this package
p : Provide package name

Upgrade RPM Package

You can also upgrade package using rpm command it is similar to installing one, but it will automatically uninstall existing package version of the package before installing the new one. If the old version not found the system, this command still install it.

# rpm -Uvh MySQL-client-3.23.57-1.i386.rpm
Preparing... 			########################################### [100%]
1:MySQL-client          ###########################################

Uninstall RPM Package

You can remove or uninstall rpm package using -e option as shown below.

# rpm -ev elinks

Install Package Ignoring Dependencies

# rpm -ivh --nodeps pants.rpm

Check an RPM Signature Package

Check the GPG signature of package before installing it. Type the below command:

# rpm --checksig pidgin-2.7.9-5.el6.2.i686.rpm
pidgin-2.7.9-5.el6.2.i686.rpm: rsa sha1 (md5) pgp md5 OK

Verify All The RPM Package

Type the below command to verify the all the rpm package on the system.

# rpm -Va
.......T.    /usr/local/psa/admin/plib/modules/atism/version
SM5....T.  c /etc/sysconfig/tomcat6
......G..  c /etc/tomcat6/catalina.policy
......G..  c /etc/tomcat6/catalina.properties
......G..  c /etc/tomcat6/context.xml
......G..  c /etc/tomcat6/log4j.properties
......G..  c /etc/tomcat6/logging.properties
S.5...GT.  c /etc/tomcat6/server.xml
S.5....T.  c /etc/tomcat6/tomcat6.conf
......G..  c /etc/tomcat6/web.xml
......G..    /usr/share/tomcat6
......G..    /usr/share/tomcat6/bin/bootstrap-6.0.24.jar
......G..    /usr/share/tomcat6/bin/catalina-tasks.xml
......G..    /usr/share/tomcat6/bin/tomcat-juli-6.0.24.jar
.M.......    /var/cache/tomcat6/temp
.....U...    /var/cache/tomcat6/work
.M...UG..    /var/log/tomcat6
.M.....T.    /var/log/tomcat6/catalina.out
S.5....T.  c /etc/inittab

Thanks:)

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment