Red Hat Linux 7 Unleashed

Red Hat Linux 7 Unleashed

By William Ball

Managing Software with RPM

Years ago, installing software on your Linux box meant untarring a file in your root system directory (/). Keeping track of what was where and trying to uninstall it was a mess, not to mention even knowing what version of the software you had.

I once removed an old library because I thought it wasn't in use anymore and I needed the disk space. After I deleted the file, half the commands on my system stopped working! Turns out there were dependencies on that library that I didn't know about.

Linux has grown to be much more sophisticated. Now it has package management tools that help you maintain a database of installed software and their files, which allows you to perform powerful queries and verification of your system.

One such tool is the Red Hat Package Manager, which is most commonly referred to as RPM. Some other distributions have their own package management tool, such as debian, but RPM is quickly becoming the standard for many distributions.

Installing

One of the most common tasks that you will use RPM for is installing new software packages. RPM packages typically are in one file having a name such as banana-1.0-1.i386.rpm, which includes the package name (banana), version (1.0), release (1), and architecture (i386). If you mount your Red Hat Linux CD-ROM and look under the directory Redhat/RPMS, you will see the hundreds of software packages that make up the Red Hat Linux distribution.

The typical command to install a package is

[root@cartoons]# rpm -ivh banana-1.0-1.i386.rpm

One of the more complex commands allows you to install packages via FTP rather than a CD-ROM or local disk:

[root@cartoons]# rpm -i ftp://ftp.redhat.com/pub/RPMS/banana-1.0-1.i386.rpm

RPM packages can "depend" on other packages, which means that they require other packages to be installed in order to run properly. If you try to install a package for which there is such an unresolved dependency, you'll see

[root@cartoons]# rpm -ivh boat-1.0-1.i386.rpm
 failed dependencies:
         banana is needed by boat-1.0-1
[root@cartoons]#

To resolve failed dependencies, install the requested packages. If you want to force the installation anyway (a bad idea since the package probably will not run correctly), use the -nodeps option.

Uninstalling

After you have been using your Red Hat Linux system for a period of time, you may decide to remove a package because you never use it or you need to free up some disk space. RPM makes it easy, doing all the hard work for you.

Uninstalling a package is just as simple as installing. You use the following command:

[root@cartoons]# rpm -e banana

Notice that we used the package name "banana," rather than the name of the original package file banana-1.0-1.i386.rpm.

You can encounter a dependency error when uninstalling a package if some other installed package depends on the one that you are trying to remove. For example:

[root@cartoons]# rpm -e banana
 removing these packages would break dependencies:
         banana is needed by boat-1.0-1
[root@cartoons]#

You can force RPM to ignore these dependencies by using the -nodeps option, but this option is not recommended because it can leave your system in an unstable state.

Upgrading

Upgrading a package is similar to installing one. The upgrade command is

[root@cartoons]# rpm -Uvh banana-2.0-1.i386.rpm
 banana                       ###################################
[root@cartoons]#

What you don't see on the preceding command is that RPM automatically uninstalled old versions of the banana package. In fact, you may want to always use -U to install packages because it works fine even when there are no previous versions of the package installed. Because RPM performs intelligent upgrading of packages with configuration files, you may see a message such as saving /etc/banana.conf as /etc/banana.conf.rpmsave. This means that during the upgrade, RPM considered your changes to the existing file to be potentially incompatible with the new configuration file in the new package. RPM saved your original configuration file and installed a new one. You should investigate and resolve the differences between the two files as soon as possible to ensure that your system continues to function properly.

Because upgrading is really a combination of uninstalling and installing, you can encounter regular errors from those modes, plus one additional error: If RPM thinks you are trying to upgrade to a package with an older version number, you will see

[root@cartoons]# rpm -Uvh banana-1.0-1.i386.rpm
 banana    package banana-2.0-1 (which is newer) is already installed
 error: banana-1.0-1.i386.rpm cannot be installed
[root@cartoons]#

To cause RPM to upgrade anyway, include --oldpackage in the upgrade command:

[root@cartoons]# rpm -Uvh --oldpackage banana-1.0-1.i386.rpm
 banana                       ####################################
[root@cartoons]#

Querying

You can query the database to find installed packages by using the rpm –q command. A simple use is rpm -q banana, which will print the package name, version, and release number of the installed package banana. For example:

[scooby@cartoons]$ rpm -q banana
 banana-2.0-1
[scooby@cartoons]$

Package Specification Options

Instead of specifying the package name, you can use the Package Specification Options with -q to specify the package(s) that you want to query. These options include the following:

Information Options

You can specify what information to display about queried packages. The following options are used to select the type of information for which you are searching:

For those options that display file lists, you can add -v to the query command to view the list in the familiar ls -l format.

Here's an example of doing a more sophisticated query:

[scooby@cartoons]$ rpm -qi kernel
Name        : kernel                       Relocations: (not relocateable)
Version     : 2.2.16                           Vendor: Red Hat, Inc.
Release     : 5.0                  Build Date: Wed 26 Jul 2000 09:13:08 PM EST
Install date: Sat 05 Apr 2000 08:44:13 AM EDT     Build Host: porky.redhat.com
Group       : System Environment/Kernel    Source RPM: kernel-2.2.16-17.src.rpm
Size        : 15122940                         License: GPL
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Summary     : The Linux kernel (the core of the Linux operating system).
Description :
The kernel package contains the Linux kernel (vmlinuz), the core of your
Red Hat Linux operating system.  The kernel handles the basic functions
of the operating system:  memory allocation, process allocation, device
input and output, etc.

For more details about using RPM, check out [scooby@cartoons]$ man rpm.

Share ThisShare This

Informit Network