Skip to content

rpm command in Linux (package management)

The rpm command is responsible for installing, removing, updating, converting the packages. This command is first organized into operating modes, which may be: querying, verifying, integrity, installing, removing, updating, and rebuilding the rpm database. Each operating mode may or may not contain several options available.

The rpm is related to the Debian dpkg, and it also requires that each dependency be satisfied manually, as well as the packages downloaded manually. These are rarely used commands when it comes to installing packages in the distribution repositories, since Yum is apt are very versatile, but they allow third-party packages to be installed manually.

The most common operating modes are:

To query the database

# rpm {-q|--query} [query options] package_name

Example:

# rpm —q bash
bash-2.05b-207

To check the status of the packages

# rpm {-v|--verify} package_name

Example:

# rpm -V snort-2.0.1-98.i586.rpm
Package snort-2.0.1-98.i586.rpm is not installed

To verify the signature and integrity of the packages

# rpm {-K|--checksig} package_name

Example:

# rpm -K libpcap-0.7.2-37.i586.rpm
libpcap-0.7.2-37.i586.rpm: sha1 md5 gpg OK

To install a new package:

# rpm {-i|--install} [installation options] package_name

Example:

# rpm —i libpcap-0.7.2-37.i586.rpm

To install a new package showing installation details:

# rpm —ivh libpcap-0.7.2-37.i586.rpm
Preparing... ######################## [100%]
1:libcap #################### [100%]

To update a package:

# rpm {-u|--upgrade} [installation options] package_name

Example:

# rpm -U libpcap-0.7.2-37.i586.rpm

Package libpcap-0.7.2-37 is already installed

To remove a package:

# rpm {-e|--erase} [removal options] package_name

Example:

# rpm —and libpcap-0.7.2-37.i586.rpm

To redo the RPM database:

# rpm {--initdb|--rebuilddb}

Example:

# rpm --initdb

To query a package’s dependencies:

# rpm {—qPr}

Example:

# rpm —QPR BitTorrent-5.2.2-1-Python2.4.noarch.rpm
/usr/bin/python2.4
python >= 2.3
python (abi) = 2.4
python-crypto >= 2.0
Python-Psyco
python-twisted >= 2.0
Python-Zopeinterface
rpmlib (CompressedFilenames) = 2.6

To install a package ignoring dependencies (a very stupid thing to do):

# rpm {—ivh --nodeps}

Example:

# rpm -ivh --nodeps BitTorrent-5.2.2-1-python2.4.noarch.rpm <br></br>
Preparing... ######################## [100%]
1:BitTorrent #################### [100%]

To list recently installed packages:

# rpm {—qa --last}

Example:

# rpm -qa --last
kernel-headers-3.14.34-27.48.amzn1.x86_64 Fri, 06 Mar 2015 11:55:01 PDT
graphviz-gd-2.38.0-18.44.amzn1.x86_64 Fri, 06 Mar 2015 11:55:00 PDT
file-devel-5.19-7.26.amzn1.x86_64 Fri, 06 Mar 2015 11:55:00 PDT

To find out which package a file belongs to:

# rpm {—qf file}

Example:

# rpm -qf /usr/bin/htpasswd
httpd24-tools-2.4.10-15.58.amzn1.x86_64

To learn information about a particular installed package:

# rpm {—qi package_name}

Example:

# rpm -qi httpd24 <br></br>
Name: httpd24
Version: 2.4.10
Release: 15.58.amzn1
Architecture: x86_64
Install Date: Fri, Feb 13, 2015 9:56:14 PM BRST
Group: System Environment/Daemons
Filesize: 3792099
License: ASL 2.0
Signature: RSA/SHA256, Thu 12 Feb 2015 17:35:50 PM EDT, Key ID bcb4a85b21c0f39f
RPM source: httpd24-2.4.10-15.58.amzn1.src.rpm
Build Date: Thu Feb 12, 2015 2:43:53 PM BRST
Build Host: build-64003.build
Relocations: (not relocatable)
Packager: Amazon.com, Inc.
Vendor: Amazon.com
Webbadress: http://httpd.apache.org/
Summary: Apache HTTP Server
Description:
The Apache HTTP Server is a powerful, efficient, and extensible web server.

To verify the integrity of the files installed with the package database:

# rpm {—Go}

Example:

# rpm -Go
S.5... T. c /etc/sysconfig/svnserve
... THE... c/etc/localtime
..?... /usr/sbin/glibc_post_upgrade.x86_64
S.5... T. c /etc/httpd/conf/httpd.conf
..?... /usr/sbin/suexec

The most common package information query options are:

    • a List all packages installed on the system;
  • -f file: Lists the name of the package containing the searched file;
  • -p packagename: Shows whether a particular package is installed;
  • -i package-name: Shows extra information about a particular package;
  • -l package-name: Shows the list of files a package contains;
  • -R package-name: Shows the list of dependencies that a package needs to be installed.

The most common package installation and upgrade options are:

  • —force: This option forces the installation of a package and its files even if it is already installed. This option even forces the installation of an older package on top of a newer one;
  • -h: This option shows the installation progress;
  • ---nodeps: This option disables the dependency check for installing a package;
  • -v: Show extra information during the installation and upgrade of the packages;
  • -vv: Shows much more information during the installation and upgrade of the packages. Generally used by developers.

The options for uninstalling the packages are:

  • —nodeps: Disables dependency checking, uninstalling the package even if it is needed by others;
  • —test: Tests the removal of the package without actually removing it. It is useful for testing whether removing the package will cause any damage to the system or application.

Prefer to use the —U mode when updating a package to a newer version, so the older package will be removed, the new package will be installed, and the settings will be maintained.

As you can see, the use of rpm is complicated at first sight and impractical, since the administrator has to download the packages and install the dependencies manually. To make everything easier, RPM-based distributions adopted YUM.

Learn how to configure the Pfsense firewall in practice with the Linux Certification Pfsense Firewall Training!

You can register here. If you already have an account, or want to create one, just log in or create your user here.