include("site.inc"); $template = new Page; $template->initCommon(); $template->displayHeader(); ?>
The primary RPM command is simply rpm. One of the original goals of the RPM system is providing ease of use. In support of this goal, just about everything you want to do with the RPM system can be done with this one command. For most usage, the command-line parameters to the rpm command determine the actions it should take.
The rpm command performs the most common package-management functions, along with a host of uncommon functions as well. The table below lists the main operations you can perform with the rpm command and the command-line options to specify the given operations.
Operation | Short Option | Long Option |
---|---|---|
Upgrade/install | -U | --upgrade |
Install | -I | --install |
Remove | -e | --erase |
Query | -q | --query |
Verify | -V | --verify |
Check signature | -K | --checksig |
Freshen (upgrade) already-installed package | -F | --freshen |
Initialize database | None | --initdb |
Rebuild database | None | --rebuilddb |
Table 2.1. The main rpm operations
Using this table as a guide, you can explore the options to the rpm command. To install or upgrade a package, use the -U command-line option:
rpm -U filename.rpm
For example, to install the xcopilot RPM used as an example in this chapter, run the following command:
rpm -U xcopilot-0.6.6-3.i386.rpm
To get extra feedback, you can use a command like the following, with the -h and -v options in conjunction with the –U option:
rpm -Uhv xcopilot-0.6.6-3.i386.rpm
When you run this command you will see more output than the default, which is no output unless there are errors. With the –h option, the rpm command will print a series of hash marks, #, to provide feedback that the command is still running. With the –v option, the rpm command provides more verbose messages.
Installing a Package | |
---|---|
The most common command to install a package is: rpm -Uhv package_file.rpm This command upgrades a package with extra output. If the package has not been installed, this command installs the package. See Chapter 3, Using RPM for more on upgrading and installing. |
To remove a package (called erase in RPM terminology), use the –e command-line option:
rpm –e package_name
Using File Extensions | |
---|---|
Notice that you install a package file using the file name that ends in .rpm, but uninstall or erase a package without the .rpm extension. This is because you install RPM files, but once installed, you work with the installed packages. The file name and the package name do not have to correspond, but typically (and sanely) they have the same base name. |
To list every RPM package installed on your system, use a command like the following.
rpm –qa
Expect to wait while this command completes. Most Linux systems have numerous packages installed, which will result in many lines of output. To better see the output, you can pipe this command to the more command, as shown following:
rpm –qa | more
You will then see the package listing one screen at a time.
rpm Options | |
---|---|
Chapter 21, RPM Command Reference lists all the options for the rpm command. |
In addition to rpm, the RPM system includes a few more commands, including rpmbuild and rpm2cpio.
The rpmbuild command helps build RPM packages. I describe its usage in depth in Part II of this book.
The rpm2cpio command exports an RPM package file int the format that the cpio command expects. The cpio command works with many tape-backup packages. You can also take advantage of the fact that cpio can list the individual files in a cpio archive or extract files. To list the files in an RPM package, use a command like the following:
rpm2cpio package_file.rpm | cpio –t
For example, the following command lists all the files in the xcopilot package:
rpm2cpio xcopilot-0.6.6-3.i386.rpm | cpio –t
To display:
./etc/X11/applink/Applications/xcopilot.desktop ./usr/bin/xcopilot ./usr/doc/xcopilot-0.6.6 ./usr/doc/xcopilot-0.6.6/README ./usr/include/X11/pixmaps/xcopilot.xpm ./usr/include/X11/pixmaps/xcopilot2.xpm 3120 blocks
The rpm2cpio command can also help if you want to extract a single file from the RPM package, using the cpio –ivd command-line options, as follows:
rpm2cpio xcopilot-0.6.6-3.i386.rpm | cpio –ivd usr/doc/xcopilot-0.6.6/README
This command will output local usr/doc/xcopilot-0.6.6/ subdirectories and the README file located under usr/doc/xcopilot-0.6.6/.
The –i option tells cpio to extract files. The –d option tells cpio to make any local subdirectories as needed (usr/doc/xcopilot-0.6.6/, in this example), and the –v option asks cpio to politely output verbose messages about what it does. Of course, verbose is in the eye of the beholder; with many Unix and Linux commands, verbose output is still somewhat terse.