Introduction to Linux Commands: The rpm Command

What is rpm?

RPM stands for Red Hat Package Manager because it was created for the Red Hat Linux distribution but is now used by others such as Mandriva and SuSE. RPM is both the file extension, as well as the command used to install the packages. So don't get confused when you are told to "rpm the rpm file". The rpm format has become the baseline format for the Linux Standards Base which is a consortium who's goal it is to develop a standard for all Linux distributions to follow.

Basic Usage

The rpm command is fairly simple to use, once you understand the various switches and arguments. The command structure looks like this:

rpm [ACTION/OPTION] FILENAME.rpm

There are two types of actions: Querying, Installing/Upgrading/Removing. A query option is used when you want to know if a package is installed on a machine and what version is installed. The install/upgrade/remove action is used to install, remove, or upgrade a package. NOTE: Any of the installing, upgrading, removing commands must be run as root. The query command can be run as a standard user.

To check to see if a package is installed on your machine you would issue the command rpm -q package_name. Notice you do not add the "rpm" extension at the end of the package name. If you issue the command rpm -q gnome-terminal you might see the results:

gnome-teriminal-2.24.2-2.fc10.i386

If gnome-terminal was not installed on your machine you would see:

"package gnome-terminal is not installed"

Say you have downloaded an rpm file to install (We'll go with aterm-1.0.1-4.i386.rpm). If you want to install you would issue the command:

rpm -i aterm-1.0.1-4.i386.rpm

and the package would install. Running the above command however, will give you no feedback. I like to add a couple of switches so I know what is going on. By adding the v (for verbose output) and the h (for displaying "#" symbols for progression of installation) I would see something like you see below. First the command:

rpm -ivh aterm-1.0.1-4.i386.rpm

and now the output:

Preparing… ################################################[100%]

1: aterm ################################################ [100%]

Once the installation is done you will be back at your command prompt.

Now let's say you want to remove aterm. To remove a package with rpm you would use the "-e" switch like so:

rpm -h aterm

and aterm would be removed. NOTE: You can not use the "v" and "h" arguments with the "e" argument.

Final Thoughts

The Red Hat Package Manager is a very powerful and very simple to use installation system. With the help of this article you now know how to do the basic tasks with rpm. There is much more you can do with rpm, but that is best left for a more in-depth article.

This post is part of the series: Simplify Linux application installation and archiving

If you are new to Linux than you might be baffled as to how to handle two important tasks: Application installation and directory archiving. Never fear, Bright Hub is hear. In this series of articles you will learn how to master the tools to help you tackle these tasks.
  1. Simplifying Linux Installation and Archiving
  2. Linux Command Line: apt-get
  3. Linux Command Line: urpmi
  4. Linux Command Line: rpm
  5. Linux Command Line: tar
  6. Linux Command Line: bzip2/bunzip2