What Is Linux RPM And Installing, Uninstalling, Updating, Querying,Verifying RPM

What is RPM?

Anybody who works with Linux knows what RPM is unless a newbie. RPM stands for redhat package manager. Although RPM was designed originally for REDHAT Linux, any other Linux version supports for RPM.

What can RPM do for you?

RPM is a command line system used in installing, uninstalling, updating, querying and verifying software packages. I will show you some common use of RPM command first and then advance uses followed by RPM options. If you install CentOS in a new PC and you want to install other software packages, you can use RPM packages. The advantage compared to other formats is that, RPM handles file management carefully.

RPM package example.

Cheese is a Photobooth-inspired GNOME application for taking pictures and videos from a webcam cheese-2.28.1-7.el6.i686.rpm. Cheese is the package name, version is 2.28.1, release is 7 and architecture .i686.

Where to find RPM?

There are several options available to get RPM packages. One option is your software CD/DVD. Second option is through the CentOS Mirror or RedHat (Need account) or any open repository websites. I will show you few examples from each of the operations installing, uninstalling, upgrading, querying and verifying.

Querying.

You can use below parameters along with "q":

-a – query all installed package.
-f – query the package which owns the file.
-c – displays list of marked configuration file.
-i – displays information about the RPM package.
-l – displays list of file that package contains.
-s – displays the state of the file.

Below option helps to check what already installed on the host:

[[email protected] Desktop]$ rpm -qa
xorg-x11-xinit-1.0.9-13.el6.i686
libgnomekbd-2.28.2-2.el6.i686
startup-notification-0.10-2.1.el6.i686
xdg-user-dirs-0.12-4.el6.i686
at-spi-1.28.1-2.el6.centos.i686
openobex-1.4-7.el6.i686
.
.
.

Since it is a long queue, you can use grep command to find about particular package.

[[email protected] Desktop]$ rpm -qa | grep cheese
cheese-2.28.1-7.el6.i686

You can use below option to query and get information about package:

[[email protected] Desktop]$ rpm -qi iptables
Name : iptables Relocations: (not relocatable)
Version : 1.4.7 Vendor: CentOS
Release : 4.el6 Build Date: Tue 19 Jul 2011 03:19:36 PM EDT
Install Date: Thu 15 Dec 2011 11:36:36 PM EST Build Host: c6b5.bsys.dev.centos.org
Group : System Environment/Base Source RPM: iptables-1.4.7-4.el6.src.rpm
Size : 719035 License: GPLv2
Signature : RSA/SHA1, Mon 26 Sep 2011 12:10:49 AM EDT, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
URL : http://www.netfilter.org/
Summary : Tools for managing Linux kernel packet filtering capabilities
Description :
The iptables utility controls the network packet filtering code in the
Linux kernel. If you need to set up firewalls and/or IP masquerading,
you should install this package.
[[email protected] Desktop]$

To find out which package owns it,

$ rpm -qf /usr/bin/ggv

To find information about RPM, use the following command:

$ rpm -qip crontabs-1.10-7.noarch.rpm

Perhaps you now want to see what files the crontabs RPM installs. You would enter the following:

$ rpm -qlp crontabs-1.10-5.noarch.rpm

Installing packages.

Example installing cheese package:

[email protected] Desktop]$ rpm -qi cheese
package cheese is not installed

[[email protected] Desktop]# rpm -ivh cheese-2.28.1-7.el6.i686.rpm
warning: cheese-2.28.1-7.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%] 1:cheese ########################################### [100%] [[email protected] Desktop]#

If package already installed, then you can try with below parameter:

$ rpm -ivh –replacepkgs cheese-2.28.1-7.el6.i686.rpm

Upgrading.

Upgrading a package is similar to installing one. As part of upgrading a package, RPM automatically uninstalls any old versions of the foo package. In fact, you may want to always use -U to install packages which works even when there are no previous versions of the package installed. Type the following command at a shell prompt.

$ rpm -Uvh cheese-2.28.1-7.el6.i686.rpm

Uninstalling.

Uninstalling a RPM package is quite easy:

$ rpm –e cheese-2.28.1-7.el6.i686.rpm

Sometimes you may get the following error:

[[email protected] Desktop]$ rpm -e iptables-1.4.7-4.el6.i686
error: Failed dependencies:
libip6tc.so.0 is needed by (installed) iptables-ipv6-1.4.7-4.el6.i686
libxtables.so.4 is needed by (installed) iproute-2.6.32-17.el6.i686
libxtables.so.4 is needed by (installed) iptables-ipv6-1.4.7-4.el6.i686
iptables >= 1.4.5 is needed by (installed) iproute-2.6.32-17.el6.i686
iptables = 1.4.7-4.el6 is needed by (installed) iptables-ipv6-1.4.7-4.el6.i686
iptables >= 1.2.8 is needed by (installed) system-config-firewall-base-1.2.27-5.el6.noarch
[[email protected] Desktop]$

In this case, you can use –nodeps option to ignore the dependencies and continue uninstall.

Note: You can also use –nodeps while installing the package.

Verifying.

To verify the package that owns that program, but you do not know which package owns ‘paste’. Enter the following command.

$ rpm -Vf /usr/bin/paste

Another feature is the file verification. If you have accidentally deleted or remove a file you can verify the changes and restore them.

[[email protected] Desktop]/ rpm –V iptables

To verify all packages:

[email protected] Desktop]/ rpm –Va

To verify installed packages:

[email protected] Desktop]/ rpm –Vp cheese-2.28.1-7.el6.i686.rpm

Misc.

Another example to check binary RPM version.

# which partprobe
/sbin/partprobe

# rpm -qvilf /sbin/partprobe
Name : parted Relocations: (not relocatable)
Version : 1.8.1 Vendor: CentOS
Release : 23.el5 Build Date: Wed 21 Jan 2009 09:51:13 AM GMT
Install Date: Wed 01 Apr 2009 11:30:30 PM BST Build Host: builder16.centos.org
Group : Applications/System Source RPM: parted-1.8.1-23.el5.src.rpm
Size : 1386546 License: GPLv2+
Signature : DSA/SHA1, Mon 09 Mar 2009 01:48:52 AM GMT, Key ID a8a447dce8562897
Summary : The GNU disk partition manipulation program.

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author Archive Page

Have anything to say?

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

All comments are subject to moderation.