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 bashbash-2.05b-207
To check the status of the packages
# rpm {-v|--verify} package_name
Example:
# rpm -V snort-2.0.1-98.i586.rpmPackage 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.rpmlibpcap-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.rpmPreparing... ######################## [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.4python >= 2.3python (abi) = 2.4python-crypto >= 2.0Python-Psycopython-twisted >= 2.0Python-Zopeinterfacerpmlib (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 --lastkernel-headers-3.14.34-27.48.amzn1.x86_64 Fri, 06 Mar 2015 11:55:01 PDTgraphviz-gd-2.38.0-18.44.amzn1.x86_64 Fri, 06 Mar 2015 11:55:00 PDTfile-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/htpasswdhttpd24-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: httpd24Version: 2.4.10Release: 15.58.amzn1Architecture: x86_64Install Date: Fri, Feb 13, 2015 9:56:14 PM BRSTGroup: System Environment/DaemonsFilesize: 3792099License: ASL 2.0Signature: RSA/SHA256, Thu 12 Feb 2015 17:35:50 PM EDT, Key ID bcb4a85b21c0f39fRPM source: httpd24-2.4.10-15.58.amzn1.src.rpmBuild Date: Thu Feb 12, 2015 2:43:53 PM BRSTBuild Host: build-64003.buildRelocations: (not relocatable)Packager: Amazon.com, Inc.Vendor: Amazon.comWebbadress: http://httpd.apache.org/Summary: Apache HTTP ServerDescription: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_64S.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.