Networking / Beginners

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 distributions, 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 program 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*

Finally, you can remove a package by using the -e switch:

$ rpm -e send*

Note that to use the rpm command, you should log on as root.

[Previous] [Contents] [Next]