There are basically two
types of rpm packages:

  • Source rpm, with the extension .src.rpm
  • Binaries, with the extension .rpm

Both types are handled with the rpm command, but
we will only talk about binaries in this article.

First of all, be careful when you download rpm binaries because they
are usually organized by architecture in the FTP servers. So, make
sure that you download the one that corresponds with the computer
architecture
that you are running (i386, i586, sparc, etc.).

Once the file has been downloaded, it does not really matter which
directory you are going to install it from. Nevertheless, you will
notice that Red Hat already includes in the filesystem a special
directory that is meant to hold these packages before installation. It
is not necessary that you use them, but I suppose that it helps
keep the filesystem tidy, and if the box is administered by several
people it also helps the rest of the team know what is going on at a
glance.

The abovementioned directory can be found in
/usr/src/redhat/RPMS,
but keep in mind that this is something particular to the Red Hat
Distribution. I ignore what it is like in the case of SuSE, Debian,
Caldera, or any other Linux distribution.

Once we had a basic introduction, let us see how to use the
rpm command.

To start with, and in order to see all the command options, just enter
rpm --help at the command prompt. You may see the screen
scroll by becausethere are so many options. If you prefer, use the
pipe to display the information in a more controlled fashion: rpm
--help | less
. Another choice is to hold down
Shift+PageUp to scroll back up and read the top of the
instructions page.

Now, let us get into the action. The generic command to install a
package is rpm -i[options] [rpm package]. For example:
rpm -i gnucash-1.2.5-1.i386.rpm would install the gnucash
package. It is also quite common to also add the options
-vh so that it displays a nice hash line to give us an
idea that the installation is proceeding right. This way, the complete
command would be something like: rpm -ivh
gnucash-1.2.5-1.i386.rpm
, but it is up to you which one you
prefer.

But let us say that instead of installing a new package we need to
update an existing one. The Red Hat Package Manager (that is what
“rpm” stands for) also takes that situation into account. In this
case, you need to run rpm -U [rpm package], as in
rpm -U gnucash-1.2.5-1.i386.rpm. Of course, you can also
add the same other options mentioned above for a more visual display:
rpm -Uvh gnucash.1.2.5-1.i386.rpm if you wish. If
something goes wrong during the upgrade, we can always revert to the
older package by enter
ing: rpm -U --oldpackage [old_package_name.rpm], as in
rpm -U --oldpackage gnucash.1.2.2.i386.rpm.

Finally, if you need to uninstall an rpm package the command is just as
simple as the ones we have already seen: rpm -e [rpm
package]
, as in rpm -e gnucash-1.2.5-1.i386.rpm.
Some options are specially useful in this case. For instance,
rpm -e --nodeps gnucash (yes, it is not necessary to enter
the complete name) will uninstall the package, but without checking to
see if any dependencies are broken. Since this command cause some
problems, it is always a good idea to use the options that will
“simulate” a removal of the package prior to actually removing it:
rpm -e --test gnucash will display a list of dependencies
that would break if we actually uninstall the package.

Aside from all these operations, you can also use rpm to perform other
useful operations. For example, the rpm -q -a command
will display a list f all the rpm packages already installed in the
system, rpm -q -l gnucash will list all the files that
belong to the package gnucash, rpm -q -c gnucash will
display all the configuration files for the gnucash package, rpm
-q -d gnucash
will only list the documentation files associ
ated to the gnucash package, rpm -q -i gnucash will show
information on the package (size, packager, URL, summary, description,
etc.), while the rpm -q -R gnucash shows all the
dependencies of the package.