Using RPMs

RPM is a package management system that was originally developed by Red Hat. It has since become the package management system for the Linux Standard Base, so it is used by many Linux distributions.

Package management systems now consist of several layers, and most users will only see the user-friendly graphical interface that is provided by their particular Linux distribution. However, sometimes it is easier to execute a simple command or two from the command line. This appendix shows some common tasks you might want to perform directly using the RPM command line interface.

For example, after installing a new version of the kernel source code, you need to check the file Documentation/Changes to see what versions of software it depends on. Then, if you need to find out information about your current version of module-init-tools (for example), execute the following command. Among other things, this will print a description of the package, its version number, and a URL where you can get more information or a newer version.

$ rpm -qi module-init-tools

Name : module-init-tools Relocations: (not relocatable)

Version : 3.4 Vendor: openSUSE

Release : 56.5 Build Date: Tue Dec 2 21:14:08 2008

Install Date : Tue Dec 9 14:14:29 2008 Build Host: build12

Group : System/Kernel Source RPM: module-init-tools-3.4-56.5.src.rpm

Size : 472575 License: GPL v2 or later

Signature : RSA/8, Tue Dec 2 21:14:23 2008, Key ID b88b2fd43dbdc284

Packager : http://bugs.opensuse.org

URL : http://www.kerneltools.org/

Summary : Utilities to Load Modules into the Kernel

Description : Utilities for loading kernel modules. Included are 'insmod', 'lsmod', 'rmmod', 'depmod', and 'modprobe'. The configuration file /etc/modprobe.* can be used to pass parameters to the modules. 'depmod' should be used after compiling a new kernel to generate the dependency information. 'insmod' does not use the dependency nor the options file. Therefore, 'modprobe' is normally used to load a module.

Package Naming Conventions

The packages themselves are simply called RPMs. Packages are usually named according to the following format.

name-version-release.target.rpm

For example, the following RPM is for the package named foo. It contains version 1.0 of the software. This is the first release of the RPM. The meaning of the release varies, but it generally distinguishes multiple RPMs containing the same software. When the RPM contains object executable programs, the target will be a short mnemonic identifying the target architecture. If a package contains source code instead of executable files, the target will be src. For example:

foo-1.0-1.i386.rpm

RPM files have the .rpm suffix, but some commands expect the package name to include the suffix and others do not. Commands that work with uninstalled RPM files (like install and update) expect the package name to include the .rpm suffix. Commands that work with already installed packages, expect the package name to not include the .rpm suffix.

Install Package

The following command will install an RPM file. The i option instructs the rpm command to install the package. The v and h options are optional. The v option is for verbose, and the h option will cause hash marks (#) to be printed to show progress.

$ rpm -ivh packageName.rpm

Uninstall Package

You can remove a package by specifying the e option (erase). Notice that the .rpm suffix is not specified. This command will not work is another package has a dependency on this one.

$ rpm -e packageName

You can list the packages that are dependent on a package with the following command:

rpm -q --whatrequires packageName

Update Package

You can update a package with a newer version by specifying the U option (that is a capital U). This will cause the current version of the package to be uninstalled and the new package to be installed. If the package does not exist, the new package will be installed. The v and h options are optional and mean the same as with the install option

$ rpm -Uvh packageName.rpm

The freshen option F is similar to update, but it only affects files that are already installed.

$ rpm -F packageName.rpm

Print Package Information

The following commands will print all the information about a package. Notice that the first command prints the information for a package that is already installed, and the second command prints information about a package file.

$ rpm -qi packageName

Or,

$ rpm -qip packageName.rpm

List Files in Package

The following commands will list the files in a package. Notice that the first command below lists the files in a package that is already installed, and the second command list the files in the package file.

$ rpm -ql packageName

Or,

$ rpm -qlp packageName.rpm

Find Where File Came From

The following command will print the name of the package that caused a file to be installed on the system. If the file was not installed from a package, the command will return an error.

$ rpm -qf fileName

For example:

$ rpm -qf /bin/ls

coreutils-6.12-32.10

List Installed Packages

The following command will list all packages installed on the system.

$ rpm -qa

Verify Installed Packages

The following command will verify the files installed by all installed packages. Information about each file is compared with information saved in the RPM database when the file was installed. Any errors will be displayed.

$ rpm -Va