Looking for CentOS help? Visit our CentOS 7 help and tutorials page.

Red Hat Packages Manager – RPM is an open source organization utility for any Red Hat based structures (RHEL, CentOS and Fedora). The utility allows admins as well as users to install, uninstall, update, verify, query and manage the system software package in Linux/Unix/ systems. The system works with the .rpm format, which consolidates collected programming tasks and libraries required by the groups.

Some quick bullet points:

  • RPM stores data related to the installed packages under /var/lib/rpm databases.
  • RPM is one of many different ways to install packages in a Linux environment. If you install a package directly through source code, note that RPM won’t be able to manage it.
  • RPM’s extension, .rpm, contains all pertinent data about the bundles. For example, its origin, what it has, dependencies info, version information and so on.

There are five fundamental modes for RPM

Install : Install any RPM package.
Upgrade : Upgrade an existing RPM package.
Verify : Verify different RPM packages.
Query : Query information about RPM package.
Remove : Uninstall a RPM package.

You need to have root privilege to use RPM command.

Things to note before installing AN RPM package:

To install an RPM package, you need to have the package already in your system. Different websites provide RPM packages. You can also install the RPM packages that already come with the distribution.

Sometimes you may don’t want to download, unzip and upload RPM, in that case use RPM build. Various developers have already created RPM builds. For example: we have an RPM build for SQL buddy. You can install SQL buddy with the following command:

wget http://www.erikjacobs.com/stuff/sqlbuddy-1.3.3-1.noarch.rpm

Then you can launch SQL buddy by opening http://yourserver.com/sqlbuddy or http://youripaddress/sqlbuddy.

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

http://rpmfind.net
http://www.redhat.com
http://freshrpms.net/
http://rpm.pbone.net/

To install any RPM package

Here,
-i : install a package
pidgin : Package Name
2.7.9-5.el6.2 : Version
i686 : Architecture

Other options you may use are -vh

Here,
-v : verbose for a nice display
-h: print hash marks when the package archive is unpacked.

Once the installation is completed you will see a screen like this one:

To check dependencies of AN RPM Package before Installing

Sometimes when you try to install an RPM package you may get a message saying Failed dependencies. That means you need some other package to install that RPM
Before installing any RPM package make sure to check dependencies required by typing the following:

# rpm -qpR sqlbuddy-1.3.3-1.noarch.rpm

This will show the dependencies that needs to installed before installing sqlbuddy

To upgrade AN RPM package

To upgrade an RPM package, we have the option -u. This option will upgrade to the latest version and will also keep a backup of the old package. So if the recently upgraded package doesn’t run, then the older package will be rolled back again.

To verify AN RPM package

The option -vp (verify package) compares info of installed files of the package with the RPM database. This can be used to verify a package.

To verify all RPM packages

The option -Va will verify all RPM package in the sytem

To query AN RPM package

You may want to check your files to see which package it belongs to. For this we have command to query file -qf.

<em># rpm -qf  /usr/bin/ htpasswd</em><em>Httpd-tools-2.2.5-15.el6.centos.1.i686</em>

Here, a file  /usr/bin/ htpasswd is owned by package httpd-tools-2.2.5-15.el6.centos.1.i686

To query info FOR AN installed package

The command -qi is helpful to obtain info about an installed package.

To get info of the RPM package that you are going to install

Let’s assume that you have downloaded and unzipped a package and now you would like to know more about the downloaded package before actually installing it. You can do this by using -qip (query information package), which will show information about the RPM package.

To query all installed packageS

This command -qa queries all the installed packages.

To check an installed Package

To find whether an RPM is installed or not, we can use -q option with package name

To list all files of AN installed package

Using -ql (query list) with RPM package name will show all the files of an installed package.

To uninstall RPM package

We can uninstall any RPM package with -e option. To uninstall we can use only package name without it’s version or architecture.

To remove AN RPM Package without dependencies

For example, you may get an error saying sqllite is needed by (installed) abc-2.0.21-3.i386.rpm
This means another package is dependent on the one that you are trying to uninstall. You can bypass by using –nodeps option. This will forcefully uninstall the RPM package from the system without checking dependencies. Be careful with this.

To list imported RPM GPG key

To check all imported GPG keys type command -qa gpg-pubkey

rpm -qa gpg-pubkey*gpg-pubkey-0608b895-4bd32942gpg-pubkey-7fac7991-4614767fgpg-pubkey-0f2682c8-4cd850eegpg-pubkey-c104b9de-4e0fd2a3

To re-build corrupt RPM database

At times the RPM database might get corrupted. To rebuild the DB, use the following commands:

cd/var/lib
rm__db*
rpm--rebuilddb
rpmdb_verify Packages

Facebooktwittergoogle_plusredditpinterestlinkedinmail