The program to work with RPM packages is appropriately named
in several different modes, but the most common tasks are install,
upgrade, query, verify, and erase.
rpm -i (install)
When you install a package for the first time, you will use the
or install mode. Simply point the rpm to a binary package and execute it.
The rpm will be installed on your system. Installation normally takes
seconds. Often when installing a package, I will add the
(verbose) switch to provide more information about the process, and the
(hash bar) switch to provide progress updates via hash (#) marks
printed on the console as the package is installed. Here's an example
of installing a package:
That's it! MyPackage is now installed and ready to use.
rpm must be run as root
rpm -e (erase)
To remove an installed package, use the
-e switch to erase it.
rpm will use the database to remove all of the files for the
package. If there are other packages installed that depend on the one you
rpm will abort. You will have to force the erase with the
nodeps switch. (
nodeps can also be used to force an
installation.) Be very careful when using this switch to force an
install or erase. Removing packages that others are dependent on can have
unfortunate results. Here is the command to remove the package we
$ rpm -e MyPackage
Notice that the full version of the package is not necessary to remove it. The full name was required at installation because we were pointing to a file name. Installed packages are referenced by their name only. The package's name is everything up to the version number.
rpm -V (verify)
The verify switch is very useful. It compares the current state of a package's files to their original state upon installation. Differences are shown using a code:
Results of verifying files
|File Size differs|
|Mode differs (includes permissions and file type)|
|MD5 sum differs|
|Device major/minor number mis-match|
|readLink(2) path mis-match|
|User ownership differs|
|Group ownership differs|
If you were to run
rpm -V on a package and
discover that the size had changed for an executable, that would be a
possible sign of a security breach.
rpm -U (upgrade)
Once a package has been installed, any attempt to install a package with
the same name will result in a message that the package is already
installed. If you want to update a package to a later version, use the
-U switch to upgrade. Upgrade has another affect. When upgrade is
run on multiple package names, it will try to put the packages in order of
dependencies. In other words, required packages will be installed first.
The upgrade switch can be used whether or not a package is already
installed, so many people use it for installs as well as upgrades instead of using the
-i switch. Here is an example of using the upgrade switch to load several
In the case above, bMyPackageDep was a prerequisite for aMyPackageNew, so
even though the file names sorted in reverse order,
rpm ordered them
rpm -q (query)
Several pieces of useful information can be queried from the rpm
database. Queries can be run by any user who has read access to the rpm
database. By default, all users have read access. To run a query, use the
-q switch with the name of the package to query. This will return
the version of the package.
$ rpm -q MyPackage
The name of the package must be exactly correct. Wild cards are not
allowed. However, if you cannot remember the full name of a package, you
can use the
grep tool to help find it. Use the
-qa switch to query all installed packages and pipe the information
grep with the text you can remember. For example:
The joy of grep
$ rpm -qa | grep IBM
Besides version numbers,
rpm -q can provide
other useful information about a package. Here are some examples:
Getting information with an rpm query
|Shows the development change history for the package|
|Shows the configuration files for the package|
|Shows the documentation files for the package|
|Shows the package description|
|Shows a list of the package's files|
|Shows the dependencies for the package|
The query also has another interesting command which is run on files rather than packages.
rpm -q whatprovides
The above command will identify the package that is associated with the filename given. The filename must include the absolute path to the file, since that is how the information is stored in the rpm database.