The RedHat Package Manager (RPM) is a popular package management system. Using RPM it’s easier to install, uninstall, and upgrade software packages. Apart from that, it’s possible to query a package for details and also can verify the integrity of installed packages.
Hire Bobcares Linux Server Administrators
Get super reliable servers and delighted customers
There are two types of RPM packages, binary packages and source packages. Binary package has been compiled for a particular architecture and is ready for installation, whereas source package contains source files to build a binary package.
We will be looking into using RPM for installing, uninstalling, upgrading, querying, and verifying software packages. Building RPM packages are beyond the scope of this article.
RPM packages are usually named using the following convention:
Consider the Apache RPM package – httpd-2.0.53-3.3.i386.rpm, then
httpd – name of the software
2.0.53 – software version (that of the original software source)
3.3 – package release
i386 – architecture
Corresponding source package is httpd-2.0.53-3.3.src.rpm (note ‘src’ in the name).
2. Installing RPMs
To install a package, use -i flag, -v flag can be used to introduce some verbosity, and -h flag displays hash marked progress of the installation.
$ rpm -ivh xchm-1.2-1.i686.rpm Preparing... ########################################### [100%] 1:xchm ########################################### [100%]
Installing a package may not be always successful at first. There could be dependency issues, or conflict due to already installed packages. It is possible to do a trial run of the installation using the –test flag. Trial run will check and report possible conflicts.
RPM packages can also be installed over network.
$ rpm -ivh ftp://<rpm-site>/<path>/package.rpm $ rpm -ivh http://<rpm-site>/<path>/package.rpm
3. Uninstalling RPMs
Use -e flag to uninstall a package.
$ rpm -e xchm
Just have to specify name of the package to be removed. The package won’t be removed if some other package depends on it. To ignore the error and uninstall the package, use –nodeps flag. Using –nodeps is not recommended since it can break other installed packages.
4. Upgrading RPMs
For upgrading an already installed package, use -U flag. It will replace the old package with the newer one. The package gets installed if it can’t find the older version of same package installed. For this reason, -U flag is also used for installing a package.
$ rpm -Uvh xchm-1.7-1.i686.rpm
Sometimes you may want to downgrade an already upgraded package. In that case, use –oldpackage flag.
$ rpm -Uvh --oldpackage xchm-1.2-1.i686.rpm
While upgrading, you may get a message that a config-file is saved as config-file.rpmsave
saving /etc/httpd/conf/httpd.conf as /etc/httpd/conf/httpd.conf.rpmsave
This means that the old configuration file is not compatible with the new package, so RPM installed the new configuration file after saving the old one. You may want to check the new configuration files and customize it as per your requirement.
If you want to upgrade only those packages that are already installed, use -F flag. It will install the new package only if an older version of the same package is already installed.
5. Querying RPMs
RPM database maintains all the details of the installed packages. The database can be queried to obtain details about the installed packages.
To list all installed packages, use -qa:
$ rpm -qa chkconfig-188.8.131.52-1 checkpolicy-1.17.5-1 perl-Filter-1.30-6 freetype-2.1.9-1
To get information about an installed package, use -qi:
$ rpm -qi httpd Name : httpd Relocations: (not relocatable) Version : 2.0.52 Vendor: Red Hat, Inc. Release : 3 Build Date: Fri 15 Oct 2004 09:11:15 PM IST Install Date: Mon 05 Dec 2005 05:26:30 PM IST Build Host: tweety.build.redhat.com Group : System Environment/Daemons Source RPM: httpd-2.0.52-3.src.rpm Size : 2407463 License: Apache Software License Signature : DSA/SHA1, Wed 20 Oct 2004 10:49:42 PM IST, Key ID b44269d04f2a6fd2 Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> URL : http://httpd.apache.org/ Summary : The httpd Web server Description : This package contains a powerful, full-featured, efficient, and freely-available Web server based on work done by the Apache Software Foundation. It is also the most popular Web server on the Internet.
The order of the command-line option flags are important. The rpm command has the following general syntax:
rpm â€“MajorOperation â€“extra_options packages_or_files
The rpm -i command installs packages, rpm -q command queries packages, and rpm -qi command queries installed packages. The rpm -iq command and rpm -qi command are different.
Use -qip to get information about an RPM package.
$ rpm -qip httpd-2.0.53-3.3.i386.rpm
To list all the files owned by a package, use -ql. Use -qc to list only the configuration files and -qd to list only documentation files. Add -v option to the command to display the lists in a familiar ls -l format.
$ rpm -ql httpd /etc/httpd /etc/httpd/conf /etc/httpd/modules /etc/rc.d/init.d/httpd /usr/bin/ab
Use -qlp to get a list of all files that will be installed by an RPM package.
$ rpm -qlp httpd-2.0.53-3.3.i386.rpm
To know which package owns a file, use -qf:
$ rpm -qf /etc/httpd/conf/httpd.conf httpd-2.0.52-3
6. Verifying RPMs
This is useful for checking the integrity of installed packages. All files from the packages are checked and the details such as permissions, type, ownership, MD5 sum, etc. are validated against the RPM database.
Verification is done usig -V flag. Only discrepancies are displayed, otherwise there is no output. To verify all the installed packages, use -Va:
$ rpm -Va
To verify a particular package, use -V:
$ rpm -V httpd S.5....T c /etc/httpd/conf/httpd.conf .M...... /var/www/html
Use following mapping to interpret the verification result.
S – file Size differs
M – Mode differs (includes permissions and file type)
5 – MD5 sum differs
D – Device major/minor number mismatch
L – Symbolic link path mismatch
U – User ownership differs
G – Group ownership differs
T – File modification time differs
In the case of httpd.conf, the file was modified. Due to that the file zise (S), MD5 sum (5), and file modification time (T) got changed.
Use RPM manpages “man rpm” for details on various command-line option flags. Details on using and building RPM package is available in the RPM Guide.
His areas of interest are Performance tuning, Server monitoring, and Security. He practises Karate, reads books and listens to music.