RPM Package Manager

November 22, 2004
RPM is a recursive acronym for RPM Package Manager (Formerly known as Redhat Package Manager). It is the default package manager in RedHat as well as RedHat based Linux distributions like Mandrake, OpenSuSE, PCLinuxOS and so on [Read about these Linux distributions here ]. It is very powerful and can be used to install, remove, update software, as well as a whole lot of other things in Linux. Basically, RPM can be divided into 3 main areas of functionality.
  1. Packages - Files that are compressed and contain applications, data and other files.
  2. Database - A list of installed packages in a system.
  3. Compilation - Bundling a bunch of files into a package suitable for installation on other systems.
Here are a couple of important RPM commands that are frequently used by Linux users though now a days, they use other tools (such as Yum) which provide automatic dependency checking to achieve the same.

Querying - Know more about a package
You can query the RPM database to know more details about a particular package that is installed in your system. To see if a particular program (say gedit, a text editor) is installed or not, use -q to activate the query mode in RPM.
# rpm -q gedit
RPM usually responds with the name, version and release of the package installed or, more likely reports that it is not present. To see all the files that are installed for gedit and their full path, use the -l sub parameter with the query mode.
# rpm -q -l gedit
Here -q is the mode and -l is the submode. Usually you can bundle the mode and sub-mode parameters together as follows:
# rpm -ql gedit
You can also try...
# rpm -qlv gedit
... for a more verbose output.

To find, in which package the file /bin/sh is located, try :
# rpm -qf /bin/sh
bash-2.05b-38

...which tells that the file /bin/sh is situated in the package bash-2.05b-38.
Now to get more details about the bash package execute the following command:
# rpm -qi bash
...which will give a whole lot of details about the bash package installed in your system.

Installing and removing packages

Suppose you want to install a package (say gedit):
# rpm -ivh gedit-2.6.0-4.rpm

To update gedit to a newer version:
# rpm -Uvh gedit-2.8.0-6.rpm
The -U mode means, if this package is not installed, install it; if an older version of this package is installed, upgrade it.

There is a third installation mode, called freshening, represented by -F. This is similar to -U in that it upgrades a package that is installed, but it adds one restriction - it ignores any packages that are not of the same name as a package that is already installed on your system. So if you have a directory containing a bundle of rpms - say security patches - then you can move into that directory containing the security patches in RPM format and execute the command:

# rpm -Fvh *.rpm

... which will install only those security patches which are related to the packages that are already installed in your system and will ignore the rest.

To remove an already installed package say gedit, just type:
# rpm -e gedit

Drawbacks of RPM

RPM has one difficulty, ie it will not install a package if that package depends on another program that is not already installed on your system. This is known as a dependency issue. RedHat provides two utilities called rpmdb-redhat for RedHat enterprise linux and rpmdb-fedora for Fedora Core. Once you install one of these on your system, RPM will automatically begin suggesting dependency resolutions.

Of course, you can force RPM to install a package even without resolving a dependency problem by using the --force and --nodeps parameters to both the installation related modes and the remove mode. They ignore conflicts and dependencies respectively.

Suppose you do not want to install an RPM package but get one or more files in it. You can use a utility called rpm2cpio to convert your RPM package into a cpio package (which is more or less similar to a tarball) then use the command cpio to extract all the files into a directory as follows:
# rpm2cpio PackageName | cpio -id

This will extract all the files from the RPM package into the current directory. This is only a small subset of the power of RPM. To know more about it try:

# man rpm

0 comments: