Developer Forums | About Us | Site Map
Search  
HOME > TUTORIALS > SERVER SIDE CODING > ADMINISTRATION TUTORIALS > WINDOWS TO LINUX ROADMAP: PART 9. INSTALLING SOFTWARE


Sponsors





Useful Lists

Web Host
site hosted by netplex

Online Manuals

Windows-to-Linux roadmap: Part 9. Installing software
By Chris Walden - 2004-08-10 Page:  1 2 3 4 5

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:

Listing 1. Installing MyPackage

$ rpm -ivh MyPackage-1.0.0.i386.rpm
Preparing...                ########################################### [100%]
   1:MyPackage              ########################################### [100%]

That's it! MyPackage is now installed and ready to use.

rpm must be run as root

rpm installs and erases must be done as root, because access is required to the file system and the rpm databases.

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

SFile Size differs
MMode differs (includes permissions and file type)
5MD5 sum differs
DDevice major/minor number mis-match
LreadLink(2) path mis-match
UUser ownership differs
GGroup ownership differs
TmTime 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:

Listing 2. Interactive upgrade


$ rpm -Uvh My*.rpm
Preparing...                ########################################### [100%]
   1:bMyPackageDep          ########################################### [ 50%]
   1:aMyPackageNew          ########################################### [100%]

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

grep is a text search tool that has a wide variety of uses. By default, grep will search files to show you lines that contain the text you indicate. In our example, we searched for "IBM." grep is a powerful tool in your scripting and console work.

$ 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 changelogShows the development change history for the package
rpm -qcShows the configuration files for the package
rpm -qdShows the documentation files for the package
rpm -qiShows the package description
rpm -qlShows a list of the package's files
rpm -qRShows 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

First published by IBM developerWorks


Copyright 2004-2024 GrindingGears.com. All rights reserved.
Article copyright and all rights retained by the author.