Module – 9 Linux Package Administration RPM

The RedHat Package Manager (RPM)
  • RPM (Red Hat Package Manager) is an default open source and most popular package management utility forRed Hat based systems like (RHEL, CentOSand Fedora).
  • The tool allows system administrators and users to install, update, uninstall, query, verify and manage system software packages in Unix/Linux operating systems.
  • The RPM formerly known as .rpm file, that includes compiled software programs and libraries needed by the packages.
  • This utility only works with packages that built on .rpm format.

Some Facts about RPM (RedHat package Manager)

  • RPM is free and released under GPL (General Public License).
  • RPM keeps the information of all the installed packages under /var/lib/rpm database.
  • RPM is the only way to install packages under Linux systems, if you’ve installed packages using source code, then rpm won’t manage it.
  • RPM deals with .rpm files, which contains the actual information about the packages such as: what it is, from where it comes, dependencies info, version info etc.

There are five basic modes for RPM command

  • Install : It is used to install any RPM package.
  • Remove : It is used to erase, remove or un-install any RPM package.
  • Upgrade : It is used to update the existing RPM package.
  • Verify : It is used to query about different RPM packages.
  • Query : It is used for the verification of any RPM package.

Standard Commands and Options

The following is a list of common RPM package commands.
  • Install (rpm –i)
  • Upgrade (rpm –U)
  • Freshen (rpm –F)
  • Erase/Uninstall (rpm –e)
  • Query (rpm –q)
  • Verify (rpm –V)
  • Package version (rpm –version)
  • Help mode (rpm –help)

Where to find RPM Packages?

Below is the list of rpm sites, where you can find and download all RPM packages.

Check an RPM Signature Package

  • Always check the PGP signature of packages before installing them on your Linux systems and make sure its integrity and origin is OK.
  • Use the following command with –checksig (check signature) option to check the signature of a package called ruby-json.
# rpm --checksig ruby-json-1.5.5-1.el6.x86_64.rpm
      ruby-json-1.5.5-1.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK

How to Install RPM  Package

  • One of the major uses of RPM is installing software packages.
  • Before installing the package, RPM performs several checks.
  • It makes sure the package is not already installed. RPM will not allow the user to install a package on top of itself.
  • It checks to make sure the user is not installing an older version of the package.
  • RPM performs a dependency check
Command Syntax
    rpm –i [options]   [packages]

  • i: install a package
  • -v : verbose for a nicer display
  • -h: print hash marks as the package archive is unpacked.
# rpm -ivh zsh-4.3.10-5.el6.x86_64.rpm

warning: zsh-4.3.10-5.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY

Preparing...########################################### [100%]
1:zsh       ########################################### [100%]

How to check dependencies of RPM Package before Installing

Let’s say you would like to do a dependency check before installing or 
upgrading a package
# rpm -qpR libldb-devel-1.1.13-3.el6.i686.rpm
warning: libldb-devel-1.1.13-3.el6.i686.rpm: Header V3 RSA/SHA256 Signature, 
key ID fd431d51: NOKEY
/usr/bin/pkg-config
libldb = 1.1.13-3.el6
libldb.so.1
libtalloc-devel >= 2.0.7
libtdb-devel >= 1.2.10
libtevent-devel >= 0.9.15
pkgconfig
pkgconfig(talloc)
pkgconfig(tdb)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(VersionedDependencies) <= 3.0.3-1
rpmlib(PayloadIsXz) <= 5.2-1
  • -q : Query a package
  • -p : List capabilities this package provides.
  • -R: List capabilities on which this package depends.

How to Install a RPM Package Without Dependencies

If you know that all needed packages are already installed and RPM is just being stupid, you can ignore those dependencies by using the option –nodeps (no dependencies check) before installing the package.

# rpm –ivh libldb-devel-1.1.13-3.el6.i686.rpm

warning: libldb-devel-1.1.13-3.el6.i686.rpm: Header V3 RSA/SHA256 Signature, 
key ID fd431d51: NOKEYerror: Failed dependencies:
       libldb.so.1 is needed by libldb-devel-1.1.13-3.el6.i686 
       libtalloc-devel >= 2.0.7 is needed by libldb-devel-1.1.13-3.el6.i686
       libtdb-devel >= 1.2.10 is needed by libldb-devel-1.1.13-3.el6.i686
       libtevent-devel >= 0.9.15 is needed by libldb-devel-1.1.13-3.el6.i686
       pkgconfig(talloc) is needed by libldb-devel-1.1.13-3.el6.i686
       pkgconfig(tdb) is needed by libldb-devel-1.1.13-3.el6.i686
# rpm –ivhnodeps libldb-devel-1.1.13-3.el6.i686.rpm
warning: libldb-devel-1.1.13-3.el6.i686.rpm: Header V3 RSA/SHA256 Signature, 
key ID fd431d51: NOKEY
Preparing...               ########################################### [100%]
1:libldb-devel           ########################################### [100%]

How to check an Installed RPM Package

Using -q option with package name, will show whether an rpm installed or not.

# rpm -q openssh-server-5.3p1-84.1.el6.x86_64

openssh-server-5.3p1-84.1.el6.x86_64

# rpm -q BitTorren

# rpm –qa (will list all install package)

 

How to List all files of an installed RPM package

To view all the files of an installed rpm packages, use the -ql (query list) 
with rpm command.
# rpm -ql openssh-server-5.3p1-84.1.el6.x86_64
/etc/pam.d/ssh-keycat
/etc/pam.d/sshd
/etc/rc.d/init.d/sshd
/etc/ssh/sshd_config
/etc/sysconfig/sshd
/usr/libexec/openssh/sftp-server.........
/var/empty/sshd

How to List Recently Installed RPM Packages

Use the following rpm command with -qa (query all) option, will list all the recently installed rpm packages.

# rpm -qa –last
libldb-devel-1.1.13-3.el6.i686               Wed 25 Feb 2015 12:10:06 PM PST
xorg-x11-proto-devel-7.6-25.el6.noarch       Wed 25 Feb 2015 12:07:29 PM PST
zsh-4.3.10-5.el6.x86_64                       Wed 25 Feb 2015 09:59:26 AM PST
migrationtools-47-7.el6.noarch               Mon 23 Feb 2015 10:03:44 AM PST
perl-LDAP-0.40-1.el6.noarch                   Mon 23 Feb 2015 09:26:13 AM PST
sssd-1.9.2-82.el6.x86_64                     Mon 23 Feb 2015 09:26:07 AM PST
libipa_hbac-1.9.2-82.el6.x86_64               Mon 23 Feb 2015 09:26:03 AM PST
.......

How to Upgrade a RPM Package

If we want to upgrade any RPM package “–U” (upgrade) option will be used. One of the major advantages of using this option is that it will not only upgrade the latest version of any package, but it will also maintain the backup of the older package so that in case if the newer upgraded package does not run the previously installed package can be used again.

# rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm

Preparing… ########################################### [100%]

1:nx ########################################### [100%]

How to Remove a RPM Package

To un-install an RPM package, for example we use the package name "zsh" , not 
the original packagename  "zsh-4.3.10-5.el6.x86_64.rpm"
The -e (erase) option is used to remove package.
# rpm -ev zsh
# rpm -ev --nodeps zsh  (Remove RPM with out dependencies)

How  to Query a file that belongs which RPM Package

Let’s say, you have list of files and you would like to find out which package 
belongs to these files.

For example, the following command with -qf (query file) 
option will show you a file /etc/puppetlabs/ is own by package of 
pe-puppet-enterprise-release-3.7.1.0-1.pe.el6.noarch
# rpm -qf /etc/puppetlabs/
  pe-puppet-enterprise-release-3.7.1.0-1.pe.el6.noarch

How  to Query a Information of Installed RPM Package

  • Let’s say you have installed an rpm package and want to know the information about the package.
  • The following (query info) option will print the available information of the installed package.

# rpm -qi pe-puppet-enterprise-release-3.7.1.0-1.pe.el6.noarch

Name       : pe-puppet-enterprise-release Relocations: (not relocatable)
Version     : 3.7.1.0               Vendor: Puppet Labs
Release     : 1.pe.el6              Build Date: Fri 07 Nov 2014 02:52:23 PM PST
Install Date: Tue 17 Feb 2015 01:57:09 PM PST Build Host: geneva.delivery.puppetlabs.net
Group       : System Environment/Base   Source RPM: pe-puppet-enterprise-release-3.7.1.0-1.pe.el6.src.rpm
Size       : 19436                           License: PL Commercial
Signature   : RSA/SHA1, Fri 07 Nov 2014 03:09:42 PM PST, Key ID 1054b7a24bd6ec30
URL         : http://www.puppetlabs.com
Summary     : Simple package to ensure proper directory structure
Description :
A simple package that lays out the file structure for Puppet Enterprise systems,
and provides some basic files necessary for PE.

How  to Query documentation of Installed RPM Package

To get the list of available documentation of an installed package, use the following command with option -qdf(query document file) will display the manual pages related to “vmstat” package

# rpm -qdf /usr/bin/vmstat
/usr/share/doc/procps-3.2.8/BUGS
/usr/share/doc/procps-3.2.8/COPYING
/usr/share/doc/procps-3.2.8/COPYING.LIB
/usr/share/doc/procps-3.2.8/FAQ
/usr/share/doc/procps-3.2.8/NEWS
.....

How  to rebuild Corrupted RPM Database

Sometimes rpm database gets corrupted and stops all the functionality of rpm and other applications on the system. So, at the time we need to rebuild the rpm database and restore it with the help of following command.

# cd /var/lib

# rm __db*

# rpm –rebuilddb

# rpmdb_verify Packages

….please refer part-2 for YUM

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>