Chapter 5. Red Hat and Debian Package Managers
This chapter describes the two major Linux packaging systems, the Red Hat
Package Manager (RPM) and the Debian GNU/Linux Package Manager.
When you want to install applications on your Linux system, most often
you'll find a binary or a source package containing the application
you want, instead of (or in addition to) a
.tar.gz file. A package is a file containing the
files necessary to install an application. But note that while the
package contains the files you need for installation, the application
might require the presence of other files or packages that are not
included, such as particular libraries (and even specific versions of
the libraries), in order to be able to run. Such requirements are
known as dependencies.
Package management systems offer many benefits.
As a user, you may find you want to query the package database to find
out what packages are installed on the system and their versions. As a system
administrator, you need tools to install and manage the packages on your
system. And, if you are also a developer, you need to know how to build
a package for distribution.
Among other things, package managers:
Provide tools for installing, updating, removing, and managing
the software on your system.
Let you install new or upgraded software directly across a
Tell you what software package a particular file belongs to or
what files a package contains.
Maintain a database of packages on the system and their state, so you
can find out what packages or versions are installed on your system.
Provide dependency checking, so you don't mess up your system with
Provide PGP, MD5, or other signature verification tools.
Provide tools for building packages.
Any user can list or query packages. However, installing, upgrading,
or removing packages generally requires superuser privileges.
This is because the packages normally are installed in systemwide directories
that are writable only by root. Sometimes you can specify an alternate
directory, to install, for example, a package into your home directory or
into a project directory where you have write permission.
Both RPM and the Debian Package Manager back up old files
before installing an updated package. Not only does this let you
go back if there is a problem, but also if you've made changes
(to configuration files, for example), they aren't completely lost.
5.1. The Red Hat Package Manager
The Red Hat Package Manager (RPM) is a freely available packaging system
for software distribution and installation. In addition to Red Hat and
Red Hat-based distributions, both SuSE and Caldera are among the
Linux distributions that use RPM.
Using RPM is straightforward. A single command, rpm,
has options to perform all the package functions. For example, to find out
if the Emacs editor is installed on your system, you could say:
% rpm -q emacs
In addition, the GNOME-RPM program provides an X-based graphical
frontend to RPM (that can be run even if you are not running GNOME).
This section describes the rpm command and then
the gnorpm command that runs GNOME-RPM.
5.1.1. The rpm Command
RPM packages are built, installed, and queried with the rpm command. RPM package names usually end with
a .rpm extension. rpm has a set of modes, each with its own
options. The format of the rpm command is:
rpm [options] [packages]
With a few exceptions, as noted in the lists of options that follow, the
first option specifies the rpm
install, query, update, build, etc.), and any remaining options
affect that mode.
In the option descriptions that refer to packages, you'll sometimes
see them specified as package-name and sometimes as
package-file. The package name is the name of the
program or application, such as gif2png. The
package file is the name of the RPM
RPM provides a configuration file for specifying frequently used options.
The system configuration file is usually
/etc/rpmrc, and users can set up their own
$HOME/.rpmrc file. You can use the
--showrc option to
show the values RPM will use for all the options that may be set in an
The rpm command includes FTP and HTTP clients,
so you can specify an ftp:// or
http:// URL to install or query
a package across the Internet. You can use an FTP or HTTP URL wherever
package-file is specified in the commands presented here.
Any user can query the RPM database. Most of the other functions require
22.214.171.124. General options
The following options can be used with all modes:
- --dbpath path
Use path as the path to the RPM database.
- --ftpport port
Use port as the FTP port.
- --ftpproxy host
Use host as a proxy server for all transfers. Specified
if you are FTPing through a firewall system that uses a proxy.
Print a long usage message (running rpm
with no options gives a shorter usage message).
Update only the database; don't change any files.
- --pipe command
Pipe the rpm output to command.
Display only error messages.
- --rcfile filename
Use filename as the configuration file instead of
the system configuration file /etc/rpmrc or
- --root dir
Perform all operations within directory dir.
Print the version number of rpm.
Print debugging information.
126.96.36.199. Install, upgrade, and freshen options
Install or upgrade an RPM package. The syntax of the
install command is:
rpm -i [install-options] package_file ...
rpm --install [install-options] package_file ...
To install a new version of a package and remove an existing version
at the same time, use the upgrade command instead:
rpm -U [install-options] package_file ...
rpm --upgrade [install-options] package_file ...
One feature of -U is that if the package doesn't already exist on the
system, it acts like -i and installs it. To prevent that behavior,
you can freshen a package instead; in that case,
upgrades the package only if an earlier version is already installed. The
freshen syntax is:
rpm -F [install-options] package_file ...
rpm --freshen [install-options] package_file ...
Installation and upgrade options are:
Install or upgrade all files.
Used with --relocate to
force relocation even if the package is not relocatable.
Don't install any documentation files.
- --excludepath path
Don't install any file whose filename begins with path.
Force the installation. Equivalent to using --replacepkgs,
--replacefiles, and --oldpackage.
- -h, --hash
Print 50 hash marks as the package archive is unpacked. Use with
--version for a nicer display.
Install even if the binary package is intended for a different architecture.
Install binary package even if the operating systems don't match.
Don't check disk space availability before installing.
Install documentation files. This is needed only if
excludedocs: 1 is specified in an rpmrc file.
Don't check whether this package depends on the presence of other
Don't reorder packages to satisfy dependencies before installing.
Don't execute any preinstall or postinstall scripts.
Don't execute any scripts triggered by package installation.
Allow an upgrade to replace a newer package with an older one.
Print percent-completion messages as files are unpacked.
- --prefix path
Set the installation prefix to path for
Install the packages even if they replace files from other installed packages.
Install the packages even if some of them are already installed.
Go through the installation to see what it would do, but don't actually
install the package.
188.8.131.52. Query options
The syntax for the query command is:
rpm -q[information-options] [package-options]
rpm --query[information-options] [package-options]
There are two subsets of query options: package selection options
that determine what packages to query and information selection
options that determine what information to provide.
184.108.40.206.1. Package selection options
Query the installed package package_name.
- -a, --all
Query all installed packages.
- -f file, --file file
Find out what package owns file.
- -g group, --group group
Find out what packages have group group.
- -p package_file
Query the uninstalled package package_file.
- --querybynumber num
Query the numth database entry. Primarily
useful for debugging.
- -qf, --queryformat num
Specify the format for displaying the query output, using tags to represent different types
of data (e.g., NAME, FILENAME, DISTRIBUTION). The format specification is a variation of
the standard printf formatting.
(Use --querytags in Section 220.127.116.11, "Miscellaneous options" to view a list of available tags.
- --specfile specfile
Query specfile as if it were a package.
- --triggeredby pkg
List packages that trigger installation of package pkg.
- --whatrequires capability
List packages that require the given capability to function.
- --whatprovides capability
List packages that provide the given capability.
18.104.22.168.2. Information selection options
- -c, --configfiles
List configuration files in the package.
Display the log of change information for the package.
- -d, --docfiles
List documentation files in the package.
Dump information for each file in the package. This option must be used with
at least one of -l,
-d. The output
includes the following information in this order:
path size mtime md5sum mode owner group isconfig isdoc rdev symlink
List all files in each package.
Display package information, including the name, version, and description.
- -l, --list
List all files in the package.
List packages by install time, with the latest packages listed first.
List the capabilities this package provides.
- -R, --requires
List any packages this package depends on.
- -s, --state
List each file in the package and its state. The possible states are
normal, not installed, or replaced.
List any package-specific shell scripts used
during installation and uninstallation of the package.
22.214.171.124. Uninstall options
The syntax for the uninstall command is:
rpm -e package_name
rpm --erase package_name
The uninstall options are:
Remove all versions of the package. Only one
package should be specified; otherwise, an error results.
Don't check dependencies before uninstalling the package.
Don't execute any preuninstall or postuninstall scripts.
Don't execute any scripts triggered by the removal of this package.
Don't really uninstall anything; just go through the motions.
126.96.36.199. Verify options
The syntax for the verify command is:
rpm -V|-y| -- verify[package-selection-options]
Verify mode compares information about the installed files in a
package with information about the files that came in the original
package and displays any discrepancies. The information compared
includes the size, MD5 sum, permissions, type, owner, and group of each
file. Uninstalled files are ignored.
The package selection options include those available for query mode,
as well as the following:
Ignore missing files.
Ignore MD5 checksum errors.
Ignore PGP checking errors.
The output is formatted as an eight-character string, possibly followed by a "c"
to indicate a configuration file, and then the filename.
Each of the eight characters in the string
represents the result of comparing one file
attribute to the value of that attribute from the RPM database. A period
(.) indicates that the file passed that test. The following
characters indicate failure of the corresponding test:
||Mode (includes permissions and file type)
188.8.131.52. Database rebuild options
The syntax of the command to rebuild the RPM database is:
rpm --rebuilddb [options]
You also can build a new database:
rpm --initdb [options]
The options available with the database rebuild mode are the
and --root options
described earlier under Section 184.108.40.206, "General options".
220.127.116.11. Signature check options
RPM packages may have a PGP signature built into them. PGP
configuration information is read from /etc/rpmrc. The
syntax of the signature-check mode is:
rpm --checksig package_file...
rpm -K package_file...
The signature-checking options are:
Don't check any GPG signatures.
Don't check any MD5 signatures.
Don't check any PGP signatures.
Two other options let you add signatures to packages:
- --addsign binary-pkgfile...
Generate and append new signatures to those that already exist in the specified binary packages.
- --resign binary-pkgfile...
Generate and insert new signatures in the specified binary packages, removing any existing
18.104.22.168. Miscellaneous options
Several additional rpm options are available:
Print the tags available for use with the --queryformat option in query mode.
- --setgids packages
Set file owner and group of the specified packages to those in the database.
- --setperms packages
Set file permissions of the specified packages to those in the database.
Show the values rpm will use for all options that can be
set in an .rpmrc file.
22.214.171.124. FTP/HTTP options
The following options are available for use with ftp:// and http:// URLs in
install, update, and query modes:
- --ftpport port
Use port for making an FTP connection on the proxy FTP
server instead of the default port. Same as specifying the macro _ftpport.
- --ftpproxy host
Use host as the proxy server for FTP transfers through
a firewall that uses a proxy. Same as specifying the macro _ftpproxy.
- --httpport port
Use port for making an HTTP connection on the proxy
HTTP server instead of the default port. Same as specifying the macro
- --httpproxy host
Use host as a proxy server for HTTP transfers. Same
as specifying the macro _httpproxy.
126.96.36.199. Build options
The syntax for the build options is:
rpm -[b|t]step [build-options] spec-file ...
to build a package directly from a spec file or
to open a tarred gzipped file and use its spec file. Both forms take
the following single-character step
Perform the prep stage, unpacking source files and applying patches.
Do a list check, expanding macros in the files section of the spec file and verifying that
each file exists.
Perform the build stage. Done after the prep stage; generally
equivalent to doing a make.
Perform the install stage. Done after the prep and build stages; generally
equivalent to doing a make install.
Build a binary package. Done after prep, build, and install.
Build a source package. Done after prep, build, and install.
Build both binary and source packages. Done after prep, build, and install.
The following additional options can be used when building an rpm file:
- --buildarch arch
- --buildos os
For use with pre-3.0 versions of RPM. Build the package for architecture arch
or the operating system os.
Replaced in 3.0 with --target.
- --buildroot dir
Override the BuildRoot tag with dir when building the package.
Clean up (remove) the build files after the package has been made.
Remove the source files and the spec file when the build is done. Can be used as a
standalone option with rpm to clean up files separately from creating
Can be used with -bc and -bi to skip
Add a PGP signature to the package.
the package, set the macros _target,
_target_os to the value indicated by
Go through the motions, but don't execute any build stages. Used for testing spec files.
Set the timecheck age (the maximum age in seconds of a file
being packaged). Set to 0 to disable.
Two other options can be used standalone with rpm to recompile or
rebuild a package:
- --rebuild source-pkgfile...
Like --recompile, but also build a new
binary package. Remove the build directory, the source files, and the spec file once the
build is complete.
- --recompile source-pkgfile...
Install the named source package, and prep, compile, and install the package.
188.8.131.52. RPM examples
Query the RPM database to find Emacs-related packages:
% rpm -q -a | grep emacs
Query an uninstalled package, printing information about the
package, and list the files it contains:
% rpm -qpil ~/downloads/bash2-doc-2.03-8.i386.rpm
Install a package (assumes superuser privileges):
% rpm -i sudo-1.5.3-6.i386.rpm
GNOME-RPM is a graphical user frontend to rpm
that runs under X. You can run gnorpm even if you are not
running GNOME. When you run
gnorpm, it opens a window that lets you manage your
rpm packages via a graphical interface.
The format of the gnorpm command is:
184.108.40.206. gnorpm options
The gnorpm options are:
Specify the geometry of the main window in standard X geometry format
- -i pkgfiles, --install pkgfiles
Install the specified packages.
- -p pkgs, --packages pkgs
The packages are in files, not in the rpm database (i.e.,
they haven't been installed yet).
- -q pkgs, --query pkgs
Display a query window for the specified installed packages.
- -qp pkgfiles, --query --packages pkgfiles
Display a query window for the specified package files. This is the same as
specifying the -q and -p options.
- -U pkgfiles, --upgrade pkgfiles
Upgrade the specified packages.
- -K pkgfiles, --checksig pkgfiles
Check the signatures on the specified packages.
- -y pkgs, --verify pkgs
Verify the specified packages.
- -?, --help
Display a help message and exit.
Specify the filesystem root to use.
Display a brief usage message and exit.
220.127.116.11. The GNOME-RPM window
The GNOME-RPM main window has five parts. At the top is a menu bar with three
Menu options are Query, Uninstall, and Verify.
Menu options are Find, Web find, Install, and Preferences.
Provides online help for GNOME-RPM.
Below the menu bar is a toolbar, with buttons to Install, Unselect, Uninstall,
Query, Verify, Find, and Web find. At the very bottom of the window
is a status bar.
The rest of the window is the main panel. On the left is the package
panel, which displays package folders in a tree structure. Clicking on
a folder selects it; double-click to display the contents of the
folder (i.e., the packages in that folder) on the righthand panel.
Clicking on a package selects it; you then can use the menus and the
toolbar buttons to operate on the package. You can select several
packages at the same time and operate on them as a group. Right-clicking
on a package icon selects the package if it isn't already and presents
a menu with Query, Uninstall, and Verify options.
See the GNOME-RPM documentation and online help for full details.
Copyright © 2001 O'Reilly & Associates. All rights reserved.