
Book IX
Chapter 9
Linux Commands
773
Commands for Working with Packages and Services
The rpm command
The rpm command is the Red Hat Package Manager, a tool that simplifies
the task of managing packages on your Linux system. Although rpm was
originally developed for Red Hat Linux, it’s now found on many Linux distri-
butions, including Fedora (which is, of course, based on the Red Hat
distribution).
Here’s the basic syntax for querying the status of a package:
rpm -q [options] package
To install, upgrade, or remove a package, the basic syntax is more like this:
rpm [ -i | -u | -e ] [options] package-file
You can use quite a few options with the rpm command, but the most
common are
✦ -v: Displays verbose output. You may as well know what rpm is doing
while it chugs along.
✦ -h: Displays hash marks (#) periodically to reassure you that the pro-
gram hasn’t died.
You can use rpm to determine the status of installed packages on your
system by using the -q switch. For example, to find out what version of
Sendmail is installed, use this command:
$ rpm -q send*
Sendmail-8.12.8-4
Notice that you can use a wildcard with the package name. If you don’t have
a package whose name matches the package name you supply, you get the
message package not installed.
To install a package, you use the -i switch and specify a wildcard filename
that indicates the location of the package file. It’s also a good idea to use
the -v and -h switches. For example, to install Sendmail from a mounted
CD-ROM drive, you use this command:
$ rpm –ivh /mnt/cdrom/Fedora/Packages/sendmail*
If you want to update to a newer version of a package, you can use the -u
switch instead of the -i switch:
$ rpm –uvh /mnt/cdrom/Fedora/Packages/sendmail*
71_625873-bk09ch09.indd 77371_625873-bk09ch09.indd 773 9/21/10 10:48 PM9/21/10 10:48 PM