Using the rpm CommandThe 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 rpmTo install a package using the rpm command at the Linux command line, follow these steps:
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 rpmIf 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 rpmWhen 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:
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.
Getting Information with rpmThe 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 rpmIf 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:
Resolving Circular DependenciesVery 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. |