Using RPM
The program to work with RPM packages is appropriately named rpm
. rpm
runs
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 -i
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 -v
(verbose) switch to provide more information about the process, and the -h
(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
are removing, 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
installed above:
$ 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
S | File Size differs |
M | Mode differs (includes permissions and file type) |
5 | MD5 sum differs |
D | Device major/minor number mis-match |
L | readLink(2) path mis-match |
U | User ownership differs |
G | Group ownership differs |
T | mTime 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
rpm packages:
|
In the case above, bMyPackageDep was a prerequisite for aMyPackageNew, so
even though the file names sorted in reverse order, rpm
ordered them
correctly.
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
MyPackage-1.0.0
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
through grep
with the text you can remember. For example:
The joy of grep
|
$ rpm -qa | grep IBM
IBMWSAppDev-Product-5.0-0
IBMWSSiteDevExp-Core-5.0-0
IBMWSSiteDev-Core-5.0-0
IBMWSTools-WAS-BASE-V5-5.0-0
IBMJava118-SDK-1.1.8-5.0
IBMWSWB-samples-5.0-0
IBMWSWB-5.0-0
IBMWSAppDev-Core-5.0-0
IBMWSAppDev-5.0-0
IBMWSTools-5.0-0
Besides version numbers, rpm -q
can provide
other useful information about a package. Here are some examples:
Getting information with an rpm query
rpm -q changelog | Shows the development change history for the package |
rpm -qc | Shows the configuration files for the package |
rpm -qd | Shows the documentation files for the package |
rpm -qi | Shows the package description |
rpm -ql | Shows a list of the package's files |
rpm -qR | 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.
View Windows-to-Linux roadmap: Part 9. Installing software Discussion
Page: 1 2 3 4 5 Next Page: RPM front ends