RPM Package Manager

Managing Users and Groups within Linux

RPM - Red Hat Package Manager


The "rpm" Red Hat Package manager is one of the most popular used package management tools. Many Linux systems come with this package manager by default. RPM allows the administrator to easily manage software (packages) on their system. Dependencies and pre-requisites are automatically managed. An "rpm" package consists of program files, config files and a list of dependencies (pre-requisites). All package information is stored in a database which keeps track of all files and packages that have been installed on the system. When you use the "rpm" command to install a package, information is added to the database. Likewise, when you remove a package the database is consulted for known dependencies. As with most packaging systems, RPM has a basic outline for package naming conventions:



RPM naming conventions


RPM package names have four key fields that help identify the package visually.

Example rpm package: htop-0.8.3-1.el6.rf.i686.rpm

Name
RPM package names are generally short and descriptive. Where multiple words are used in a name they are separated by a hyphen "-"

Version
Every package should have a version number and this should be the same as the content of the package. Most version information is numeric in format. Normally the numbering conforms to the following pattern: major.minor.patchlevel

Revision
This is a release number of the package.

Architecture
"rpm" packages contain programs that have generally been compiled for a particular platform. Common identifier references are : i386 for older PCs with intel 80386 processors. i686 for newer x86 PCs. You may also see packages that contain the term "noarch", these packages may be installed on any platform.

The functionality of the "rpm" command can broken down into several sections. Each of these sections handle different functionality. Commands can be entered in the traditional manner with a single dash or the alternative way using two dashes:


rpm - Installation Mode


Basic Syntax:

rpm -i [Options]
rpm --install [Options]

rpm -U [Options]
rpm -- upgrade [Options]

rpm -e [Options]
rpm --uninstall [Options]

rpm -q [Options]
rpm --query [Options]

rpm -V [Options]
rpm --verify [Options]


rpm install Options


--force
The "--force" option allows you to replace existing packages even if you are replacing a newer version with an older version.

--hash
This option displays a "#" hash as a progress indicator during an installation. You can specify "-h" as a shortened version. Frequently used with "rpm -ihv packagename giving a hash installation progress bar along with verbose installation information.

--nodeps
This flag allows you to install a package without checking for any dependencies. Where possible you should avoid using this flag.

--test
This is a useful parameter as it allows you to simulate an installation and verify that it should work when installing for real.

-v
This flag sets the verbose option to display package names as they are installed.

-vv
The "-vv" flag sets output to "Very Verbose". Useful if you are having problems when installing a package. This flag is often used in conjunction with the "--test" flag.



Examples of a RPM installation


Installing a Package Syntax: rpm -i packagename



[root@centos Downloads]# rpm -ihv htop-0.8.3-1.el6.rf.i686.rpm
warning: htop-0.8.3-1.el6.rf.i686.rpm: Header V3 DSA/SHA1 Signature, key
ID 6b8d79e6: NOKEY
Preparing...                ########################################### [100%]
   1:htop                   ########################################### [100%]

The above example uses the install mode along with hash progress marking and verbose mode on. The package "htop-0.8.3-1.el6.rf.i686.rpm" has now been successfully installed.

Removing a Package Syntax: rpm -e packagename



[root@centos Downloads]# rpm -qa htop
htop-0.8.3-1.el6.rf.i686
[root@centos Downloads]# rpm -e htop-0.8.3-1.el6.rf.i686
[root@centos Downloads]# rpm -qa htop
[root@centos Downloads]# 

The above example first queries the package htop is installed, then we remove it using the "rpm -e htop-0.8.3-1.el6.rf.i686" command. We then check to make sure the file has been removed by issuing the "rpm -qa htop" command.

Upgrading a Package Syntax: rpm -U packagename



[root@centos Downloads]# rpm -Uhv htop-0.8.3-1.el6.rf.i686.rpm
warning: htop-0.8.3-1.el6.rf.i686.rpm: Header V3 DSA/SHA1 Signature, key
ID 6b8d79e6: NOKEY
Preparing...                ########################################### [100%]
   1:htop                   ########################################### [100%]

The above example of an upgrade will install the package "htop-0.8.3-1.el6.rf.i686.rpm", if an older version exists, it will be upgraded. If no version exists, then the package is installed. Many administrators use this as an alternative way to install a package.


Querying Packages


Basic Syntax:

rpm -q [Options]


rpm query options


-a
List all packages installed on your system. You can also use the syntax of "--all" as an alternative.

-f
Displays the package that contains a certain file. The syntax of "--file" may also be used.

-p
Queries a package file

-c
List configuration files. You may also use "--configfiles" as an alternative.

-d
List Documentation files. You may also use the "--docfiles" as an alternative.

-i
Used to display information about an installed package.

-l
List files contained within a package.

-R
List package dependencies.

Query all Packages on your system: rpm -qa



[root@centos Downloads]# rpm -qa
python-slip-gtk-0.2.20-1.el6_2.noarch
NetworkManager-0.8.1-43.el6.i686
gmp-4.3.1-7.el6_2.2.i686
sane-backends-libs-gphoto2-1.0.21-3.el6.i686
libtevent-0.9.17-1.el6.i686
dejavu-fonts-common-2.30-2.el6.noarch
gvfs-smb-1.4.3-15.el6.i686
qt-4.6.2-25.el6.i686
khmeros-fonts-common-5.0-9.el6.noarch
gnome-python2-canvas-2.28.0-3.el6.i686
biosdevname-0.4.1-3.el6.i686
libpcap-1.0.0-6.20091201git117cb5.el6.i686
libXext-1.3.1-2.el6.i686
mythes-en-3.0-6.el6.noarch
gnome-panel-2.30.2-14.el6.i686

In the above example we issued the "rpm -qa" command to query all packages on the system. The above is only a snippet from the actual output as the full listing is quite considerable in size. On my test CentOS system it reported that I had 1096 packages!

Find an individual package: rpm -qa | grep packagename



[root@centos Downloads]# rpm -qa | grep htop
htop-0.8.3-1.el6.rf.i686

Display Package Information: rpm -qpi packagename



[root@centos Downloads]# rpm -qpi htop-0.8.3-1.el6.rf.i686.rpm
warning: htop-0.8.3-1.el6.rf.i686.rpm: Header V3 DSA/SHA1 Signature, key
ID 6b8d79e6: NOKEY
Name        : htop                         Relocations: (not
relocatable)
Version     : 0.8.3                             Vendor: Dag Apt
Repository, http://dag.wieers.com/apt/
Release     : 1.el6.rf                      Build Date: Thu 11 Nov 2010
11:26:57 PM GMT
Install Date: (not installed)               Build Host:
lisse.hasselt.wieers.com
Group       : Applications/System           Source RPM:
htop-0.8.3-1.el6.rf.src.rpm
Size        : 166940                           License: GPL
Signature   : DSA/SHA1, Fri 12 Nov 2010 03:53:54 AM GMT, Key ID
a20e52146b8d79e6
Packager    : Dag Wieers 
URL         : http://htop.sourceforge.net/
Summary     : Interactive process viewer
Description :
htop is an interactive process viewer for Linux.

In the above example we used the "rpm -qpi htop-0.8.3-1.el6.rf.i686.rpm" command to query information within the package.

List Files in a Package: rpm -qlp packagename



[root@centos Downloads]# rpm -qlp htop-0.8.3-1.el6.rf.i686.rpm
warning: htop-0.8.3-1.el6.rf.i686.rpm: Header V3 DSA/SHA1 Signature, key
ID 6b8d79e6: NOKEY
/usr/bin/htop
/usr/share/applications/htop.desktop
/usr/share/doc/htop-0.8.3
/usr/share/doc/htop-0.8.3/AUTHORS
/usr/share/doc/htop-0.8.3/COPYING
/usr/share/doc/htop-0.8.3/ChangeLog
/usr/share/doc/htop-0.8.3/INSTALL
/usr/share/doc/htop-0.8.3/NEWS
/usr/share/doc/htop-0.8.3/README
/usr/share/man/man1/htop.1.gz
/usr/share/pixmaps/htop.png

The above examples shows how to list all files contained within a package. In this example we issued the "rpm -qlp htop-0.8.3-1.el6.rf.i686.rpm" command.

List files in an Installed Package: rpm -ql htop



[root@centos Downloads]# rpm -ql htop
/usr/bin/htop
/usr/share/applications/htop.desktop
/usr/share/doc/htop-0.8.3
/usr/share/doc/htop-0.8.3/AUTHORS
/usr/share/doc/htop-0.8.3/COPYING
/usr/share/doc/htop-0.8.3/ChangeLog
/usr/share/doc/htop-0.8.3/INSTALL
/usr/share/doc/htop-0.8.3/NEWS
/usr/share/doc/htop-0.8.3/README
/usr/share/man/man1/htop.1.gz
/usr/share/pixmaps/htop.png

The above example lists all files from the installed package "htop"