BigAdmin System Administration Portal
Feature Tech Tip

Short Overview of RPMs in Linux

Serge Burlyga, March 2006

Abstract: This introduction to RPMs covers different types of queries as well as tips on how to obtain information on RPMs and list their contents.


I. The Simplest Query

The query options are accessed by using the -q or --query option to the rpm command. By default the query is applied to one or more installed package listed by name at the end of the query, like this:

rpm -q <packagename> [<packagename>...]

The -q option with no additional options returns the canonical name-version-release string for a package. For example:

$ rpm -q filesystem
filesystem-2.2.1-3

II. Querying Package Files

To apply the query to a package file instead of a currently installed package, use the -p or --package option. For example:

$ rpm -qp sun-icu-2.1-6.i386.rpm
sun-icu-2.1-6

You may list more than one package file, or use shell globbing.

Note that this information was retrieved from the contents of the RPM file itself, not from the file name. Renaming the package file does not affect these values. For example:

$ mv sun-icu-2.1-6.i386.rpm charmander.sdklfj
$ rpm -qp charmander.sdklfj
sun-icu-2.1-6

All query commands may be applied to a package file simply by adding the -p option to the command.


III. Querying All Installed Packages

To apply the query to all installed package, use the -a option. Do not specify any individual RPMs to query. Without any additional options, this lists all packages installed on the system in canonical name-version-release format. For example:

$ rpm -qa | head -10
dietlibc-0.21-7
kon2-fonts-0.3.9b-18.1
man-pages-fr-0.9.7-7
kudzu-devel-1.1.21-1
basesystem-8.0-2
bogl-0.1.9-27
compat-slang-1.4.5-5
diffstat-1.31-2
elfutils-0.89-1
glib-1.2.10-11.1
[...and so forth]

All query commands may be applied to all installed packages simply by adding the -a option to the command. Be careful, as this can result in a lot of information.


IV. Useful Queries

The full list of query options is described in the QUERY OPTIONS section of the rpm man page. Here are the most useful:

General Information

The -i or --info flag returns general descriptive information about the RPM. This information includes the build date and build host name. For example:

$ rpm -qpi sun-icu-2.1-6.i386.rpm
Name : sun-icu
Relocations: (not relocateable)
Version : 2.1
Vendor: Sun Microsystems, Inc.
Release : 6
Build Date: Mon 23 Feb 2004 12:07:17 PM PST
Install Date: (not installed)
Build Host: zzz-build.Sun.COM
Group : Operation System Environment
Source RPM: sun-icu-2.1-6.src.rpm
Size : 12387614
License: ICU License -ICU 1.8.1 and later and Sun Microsystems Binary
Code License (BCL)
Signature : (none)
Packager : Sun Microsystems, Inc.
URL : http://www.sun.com/
Summary : International Components for Unicode 2.1 with Sun enhancements
Description : The sun-icu package contains ICU 2.1 version of
internationalization
libraries and header files for C and C++ programming languages with
additional Sun-specific enhancements.

Listing All Files Contained in the RPM

Use the -l or --list option to list all files in a package. For example:

$ rpm -qpl sun-icu-2.1-6.i386.rpm | head -10
/opt/sun/private/include/layout/ArabicLayoutEngine.h
/opt/sun/private/include/layout/GXLayoutEngine.h
/opt/sun/private/include/layout/IndicLayoutEngine.h
/opt/sun/private/include/layout/LEFontInstance.h
/opt/sun/private/include/layout/LEGlyphFilter.h
/opt/sun/private/include/layout/LEScripts.h
/opt/sun/private/include/layout/LESwaps.h
/opt/sun/private/include/layout/LETypes.h
/opt/sun/private/include/layout/LayoutEngine.h
/opt/sun/private/include/layout/OpenTypeLayoutEngine.h
[...and so forth]

V. Querying Individual Package Fields

The --queryformat or --qf option allows you to query rpm for one or more fields, formatting the results however you see fit. This is very useful in scripting situations. This command may be applied to one or more installed packages, to all installed packages, or to one or more RPM package files.

$ rpm -q --qf
'%{name}\t%{version}-%{release}\t%{buildhost}\t%{buildtime}\n' mozilla
mozilla-nss mozilla-nspr
mozilla 1.4-3.0.18 porky.devel.redhat.com 1064264992
mozilla-nss 1.4-3.0.18 porky.devel.redhat.com 1064264992
mozilla-nspr 1.4-3.0.18 porky.devel.redhat.com 1064264992

See the man page for additional options which allow you to control the format of the individual fields.

For a list of all fields you may query, run rpm --querytags.


VI. Removing RPMs

Use the following command to remove RPMs:

$ rpm -e {name}

Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License.


BigAdmin
  
 
 
 
BigAdmin News
Information & Resources
delivered to you.
Subscribe today!
Help us make this site better for system admins