Using the rpm Command


Using the rpm Command

The rpm command provides a way for packages to be installed or removed at the command line. It also provides several additional package management options that the desktop tools don't provide.

Installing RPM Packages with rpm

To install a package using the rpm command at the Linux command line, follow these steps:

1.

Make sure you are working as the root user; use the su command if necessary to become root.

2.

Make the directory containing the .rpm files you want to install your current working directory.

3.

Enter the rpm command with the -i (install) option, supplying the name of the package you want to install as an argument.

For example, assuming that you are working as root and want to install a package called mypackage.rpm, which is in the current directory, you would enter the following:

 [root@workstation20 you]# rpm -i opera-7.54-20050131.5-shared-qt.i386-en.rpm [root@workstation20 you]# 

If there are no problems or errors, the package is installed and no additional messages are displayed. You can then use the software according to the manufacturer or supplier's instructions.

Upgrading RPM Packages with rpm

If you use the rpm command to attempt to install a package that is already installed, you see an error message like this one:

 package mypackage is already installed 

If the package you are trying to install is a vendor-supplied upgrade or a later version of the existing package that is already installed on your system, you can automatically remove the old package and replace it with the new one by using the -U (upgrade) option with the rpm command:

 [root@workstation20 you]# rpm -U mypackage.rpm [root@workstation20 you]# 

Again, if the original package is successfully upgraded (replaced) by the newer package, no additional messages are displayed.

Dealing with Failed Dependencies Using rpm

When rpm is asked to install a software package that requires software not already installed on your system, an error message like this one is displayed:

 error: Failed dependencies:     alsa-lib is needed by ogle-0.9.1-fr3     libasound.so.2 is needed by ogle-0.9.1-fr3     libasound.so.2(ALSA_0.9) is needed by ogle-0.9.1-fr3     libdvdread >= 0.9.4 is needed by ogle-0.9.1-fr3     libdvdread.so.3 is needed by ogle-0.9.1-fr3 

Unlike the desktop package installer, the rpm command does not have the capability of automatically asking you to insert your Fedora Core 4 CD-ROMs to install needed packages that are a part of Fedora Core 4. If you are experiencing a dependency failure while trying to install a third party application and need to use the command line installer, you should first check the Fedora Core 4 CD-ROMs to see whether the package(s) you need can be found there. To check each Fedora Core 4 CD-ROM at the command line, follow these steps:

1.

Insert the CD-ROM you want to search.

2.

Type mount /mnt/cdrom to ensure that the CD-ROM is mounted.

3.

Type find /mnt/cdrom -print | grep dependency, where dependency is the name of the package or software item neededfor example, find /mnt/cdrom | grep libdvdcss to search for a package called libdvdcss.

4.

If the find command finds and lists any RPM packages by the needed name, type rpm -i to install the package(s) that find has found.

5.

Type umount /mnt/cdrom to unmount the CD-ROM.

6.

Repeat these steps for each Fedora Core 4 CD-ROM (you might need to search all of them) and for each package required to fulfill dependencies.

Remember How to Use mount, umount, find, and grep?

For a refresher on the mount and umount commands, refer to Chapter 28, "Command-Line System Administration."

For a refresher on the find and grep commands, refer to Chapter 19, "Performing Basic Shell Tasks."


If you are unable to find the needed package(s) on the Fedora Core 4 CD-ROMs, refer to the section earlier in this chapter called "Dealing with Failed Dependencies" for more suggestions on resolving failed dependencies.

Trying to Install a Fedora Package?

If your goal is to install a Fedora package from the CD-ROM at the command line, and you are experiencing dependency failures in that context, use the yum command discussed in Chapter 32, "Keeping Fedora Core Updated" instead of the rpm command discussed here.

The yum command can install many common Fedora (and even some third party) packages for you, and will automatically resolve and download needed dependencies for you.


Getting Information with rpm

The rpm command can alsoprovide you with various types of information on the software packages that are installed on your system, as well as some information about software packages that are not yet installed.

To get a listing of all software packages currently installed on your system, use the rpm command with the -q (query) and -a (all packages) options. On a typical Linux system, this list is hundreds of lines long, so be sure to save the output to a file or to pipe it to a pager:

 [root@workstation20 you]# rpm -q -a | more 

You can also search the list of installed packages to see whether a specific package is installed by piping the output of rpm to the grep command, supplying the name of the package you want to search for as an argument to grep:

 [root@workstation20 you]# rpm -q -a | grep bash bash-2.05b-5 [root@workstation20 you]# 

To learn more about any individual package that is already installed, use the -q (query) and -i (information) options, supplying the name of the package as an argument:

 [root@workstation20 you]# rpm -q -i bash Name        : bash                     Relocations: /usr Version     : 3.0                           Vendor: Red Hat, Inc. Release     : 29                        Build Date: Wed Mar 2 09:31:15 2005 Install Date: Wed Mar 23 20:51:52 2005  Build Host: porky.build.redhat.com Group       : System Environment/Shells Source RPM: bash-3.0-29.src.rpm Size        : 5121307                          License: GPL Signature   : DSA/SHA1, Tue Mar  8 18:57:41 2005, Key ID da84cbd430c9ecf8 Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> Summary     : The GNU Bourne Again shell (bash) version 3.0. Description : The GNU Bourne Again shell (Bash) is a shell or command language interpreter that is compatible with the Bourne shell (sh). Bash incorporates useful features from the Korn shell (ksh) and the C shell (csh). Most sh scripts can be run by bash without modification. This package (bash) contains bash version 3.0, which improves POSIX compliance over previous versions. However, many old shell scripts will depend upon the behavior of bash 1.14, which is included in the bash1 package. Bash is the default shell for Red Hat Linux.  It is popular and powerful, and you'll probably end up using it. [root@workstation20 you]# 

Several additional information-gathering functions are available using the rpm command; see the manual page for rpm for details.

Uninstalling Software with rpm

If you find that you no longer use a piece of software and would like to free up the space it is using, you can also use the rpm command to remove installed software packages. To remove an installed software package using rpm, supply the -e option followed by the name of the package you want to remove as an argument. You do not need to supply version numbers in the package names when removing software packages. Do not supply the .rpm extension to the filename when you call rpm -e:

 [root@workstation20 you]# rpm -e mypackage [root@workstation20 you]# 

If the software package is successfully uninstalled, you see no further output.

Sometimes you encounter dependency problems when attempting to remove a package, as can be seen in this example:

 [root@workstation20 you]# rpm -e qt error: Failed dependencies         libqt-mt.so.3 is needed by (installed) arts-1.1.3-2.2         libqt-mt.so.3 is needed by (installed) kdelibs-3.1.3-6.2         libqt-mt.so.3 is needed by (installed) kdebase-3.1.3-5.2         qt >= 1:3.1.2 is needed by (installed) kdelibs-3.1.3-6.2         /usr/lib/qt-3.1 is needed by (installed) redhat-artwork-0.73.2-1E [root@workstation20 you]# 

When this situation occurs, you have two choices:

  • Begin by removing the software packages that depend on the package that you want to remove and then remove the package.

  • Leave the package in place because other installed packages depend on it.

Don't Remove a Package If You Don't Know What It Is!

Using rpm to prune your Linux installation to save space is not a good idea. Many packages that don't appear in desktop menus are nevertheless important system packages. Removing them might remove functionality from your Linux system.


Resolving Circular Dependencies

Very rarely when using rpm to install or remove packages, you encounter circular dependencies.

The term circular dependencies refers to a situation in which two packages depend on each other, as can be seen in this illustration:

 [root@workstation20 you]# rpm -i mypackage-a.rpm error: Failed dependencies:     mypackage-b is needed by mypackage-a [root@workstation20 you]# rpm -i mypackage-b.rpm error: Failed dependencies:     mypackage-a is needed by mypackage-b [root@workstation20 you]# 

When this situation occurs, you can solve the problem by supplying all the packages involved as arguments together:

 [root@workstation20 you]# rpm -i mypackage-a.rpm mypackage-b.rpm [root@workstation20 you]# 

When you supply the packages to rpm simultaneously, rpm is able to resolve all the dependencies, allowing packages with circular dependencies to be installed or removed.



    SAMS Teach Yourself Red Hat(r) Fedora(tm) 4 Linux(r) All in One
    Cisco ASA and PIX Firewall Handbook
    ISBN: N/A
    EAN: 2147483647
    Year: 2006
    Pages: 311
    Authors: David Hucaby

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net