RPM is the abbreviation of the RedHat Package Manager. Which are a default open source and most popular package management utility for RedHat based systems. As a system administrator or a user, you will need the RPM to do some activities like Install, Update, Uninstall, Query, Verify and manage system software packages in Unix/Linux operating systems. Please be aware that RPM works with packages that built on.RPM format. As you need to have your own Linux Virtual Private Server, count on us to provide you the bests.
Please Note: To start this guide and be able to go within the solutions, a root user is needed. You should be a root user to use its privileges of managing rpm commands with their appropriate options.
Table of Contents
Tutorial Linux RPM command with example
Join us with this article to see about 20 useful and practical Examples of Linux RPM Commands. After that, you may be able to manage to install, update, remove packages in your Linux systems.
Five Basic Modes For RPM Packages
To start this guide, have a look at the below list of five basic modes of RPM packages operation:
- Install
- Remove
- Upgrade
- Verify
- Query
To use and Install RPM packages, you will use the Install mode. As you guess, you may need to erase remove or un-install any RPM package. So you will use the Remove mode. Also to update the existing RPM package, Upgrade mode is available. In case you need to Verify any RPM packages, the 4th modes are on. Finally to Query an RPM package, find the latest modes, Query.
More About RedHat Package Manager
You find RPM free which is released under GPL (General Public License).
1- Using RPM helps you to keep the information of all packages under /var/lib/rpm database.
2- You need RPM to be able to install packages under Linux systems. Remember that in case you have installed packages using source code, then rpm will not manage it.
3- 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.
Ways To Find RPM Packages
Here, there are some websites where you can find and download all RPM packages.
1-Rpmfind.net
2-Redhat.com
3-freshrpms.net
4-rpm.pbone.net
1- How To Check An RPM Signature Package
Before installing the RPM packages on your Linux systems, you need to check the PGP signature of packages. Also, make sure its integrity and origin are OK. To do this, run the following command.
[root@eldernode]# rpm --checksig pidgin-2.7.9-5.el6.2.i686.rpm
pidgin-2.7.9-5.el6.2.i686.rpm: rsa sha1 (md5) pgp md5 OK
Note: checksig (check signature)is an option to check the signature of a package called pidgin.
2- How To Install An RPM Package
Run the command below to install an rpm software package.
[root@eldernode]# rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm
Preparing... ########################################### [100%] 1:pidgin ########################################### [100%]
Note: You used the -i option. For example, to install an rpm package called pidgin-2.7.9-5.el6.2.i686.rpm.
Here are some:
RPM command And Options
-i: install a package
-v: verbose for a nicer display
-h: print hash marks as the package archive is unpacked.
3- How To Check Dependencies Of RPM Package Before Installing
In this step, you should do a dependency check before installing or upgrading a package. Have a look at the below example to learn how to to do this. To check the dependencies of BitTorrent-5.2.2-1-Python2.4.noarch.rpm package run the command below to display the list of dependencies of the package.
[root@eldernode]# 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
Have a look at:
RPM Command And Options
-q: Query a package
-p: List capabilities this package provides.
-R: List capabilities on which this package depends.
4- How to Install An RPM Package Without Dependencies
If you discretion that all required packages have been installed recently, and RPM is not needed, feel free to ignore those dependencies by using the option –nodeps (no dependencies check) before installing the package.
[root@eldernode]# rpm -ivh --nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm Preparing... ########################################### [100%] 1:BitTorrent ########################################### [100%]
To install the rpm packages by ignoring dependencies errors forcefully, you use the above command. Remember that if those dependency files are missing, you can not run the program until you install them.
5- How To Check An Installed RPM Package
Also to show whether an rpm installed or not, use -q option with the package name.
[root@eldernode]# rpm -q BitTorrent BitTorrent-5.2.2-1.noarch
6- How To Get A list all Files Of An Installed RPM Package
Use the -ql (query list) with rpm command, to view all the files of installed rpm packages
[root@eldernode]# rpm -ql BitTorrent /usr/bin/bittorrent /usr/bin/bittorrent-console /usr/bin/bittorrent-curses /usr/bin/bittorrent-tracker /usr/bin/changetracker-console /usr/bin/launchmany-console /usr/bin/launchmany-curses /usr/bin/maketorrent /usr/bin/maketorrent-console /usr/bin/torrentinfo-console
7- How to Get list Recently Installed RPM Packages
To list all the recently installed rpm packages, you can use the following rpm command with -qa (query all) option.
[root@eldernode]# rpm -qa --last BitTorrent-5.2.2-1.noarch Tue 04 Dec 2012 05:14:06 PM BDT pidgin-2.7.9-5.el6.2.i686 Tue 04 Dec 2012 05:13:51 PM BDT cyrus-sasl-devel-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:06 PM BDT cyrus-sasl-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:05 PM BDT cyrus-sasl-md5-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:04 PM BDT cyrus-sasl-plain-2.1.23-13.el6_3.1.i686 Tue 04 Dec 2012 04:43:03 PM BDT
8- How To Checklist All Installed RPM Packages
Print all the names of installed packages on your Linux system, by running the command below:
[root@eldernode]# rpm -qa initscripts-9.03.31-2.el6.centos.i686 polkit-desktop-policy-0.96-2.el6_0.1.noarch thunderbird-17.0-1.el6.remi.i686
9- How To Upgrade An RPM Package
The “–U” (upgrade) option is suitable for upgrading any RPM package. By using this option you can upgrade the latest version of any package and also maintain the backup of the older package. If the newer upgraded package does not run the previously installed package can be used again.
[root@eldernode]# rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm Preparing... ########################################### [100%] 1:nx ########################################### [100%]
10- How To Remove An RPM Package
It is turn to learn how to uninstall an RPM package. You can use the package name nx, not the original package name nx-3.5.0-2.el6.centos.i686.rpm. The -e (erase) option is used to remove the package.
[root@eldernode]# rpm -evv nx
11- How To Remove RPM Package Without Dependencies
To remove forcefully the rpm packages from the system, use –nodeps (Do not check dependencies). Consider that a particular package may break other working applications.
[root@eldernode]# rpm -ev --nodeps vsftpd
12- Query A file That Belongs To Which RPM Package
Once you have a list of files, you can find out which package belongs to these files. To do this use the below exam in the following command with -qf (query file) option that shows you a file /usr/bin/htpasswd is own by package httpd-tools-2.2.15-15.el6.centos.1.i686.
[root@eldernode]# rpm -qf /usr/bin/htpasswd httpd-tools-2.2.15-15.el6.centos.1.i686
13- Query An Information Of Installed RPM Package
After installing an rpm package, you can see the information about the package. The following -qi (query info) option will print the available information of the installed package.
[root@eldernode]# rpm -qi vsftpd Name : vsftpd Relocations: (not relocatable) Version : 2.2.2 Vendor: CentOS Release : 11.el6 Build Date: Fri 22 Jun 2012 01:54:24 PM BDT Install Date: Mon 17 Sep 2012 07:55:28 PM BDT Build Host: c6b8.bsys.dev.centos.org Group : System Environment/Daemons Source RPM: vsftpd-2.2.2-11.el6.src.rpm Size : 351932 License: GPLv2 with exceptions Signature : RSA/SHA1, Mon 25 Jun 2012 04:07:34 AM BDT, Key ID 0946fca2c105b9de Packager : CentOS BuildSystem <http://bugs.centos.org> URL : http://vsftpd.beasts.org/ Summary : Very Secure Ftp Daemon Description : vsftpd is a Very Secure FTP daemon. It was written completely from scratch.
14- How To Get The Information Of RPM Package Before Installing
To continue on this step, you have to download a package from the internet and want to know the information about a package before installing it. To print the information of a package sqlbuddy, use the following option -qip (query info package)
[root@eldernode]# rpm -qip sqlbuddy-1.3.3-1.noarch.rpm Name : sqlbuddy Relocations: (not relocatable) Version : 1.3.3 Vendor: (none) Release : 1 Build Date: Wed 02 Nov 2011 11:01:21 PM BDT Install Date: (not installed) Build Host: rpm.bar.baz Group : Applications/Internet Source RPM: sqlbuddy-1.3.3-1.src.rpm Size : 1155804 License: MIT Signature : (none) Packager : Erik M Jacobs URL : http://www.sqlbuddy.com/ Summary : SQL Buddy â Web based MySQL administration Description : SQLBuddy is a PHP script that allows for web-based MySQL administration.
15- Query Documentation Of Installed RPM Package
Another item in the Tutorial Linux RPM command is, to get the list of available documentation of an installed package, to display the manual pages related to vmstat package use the following command with option -qdf (query document file).
[root@eldernode]# 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 /usr/share/doc/procps-3.2.8/TODO Recommended Article: Tutorial Linux RPM command with example
16- How To Verify An RPM Package
To compare the information of installed files of the package against the rpm database, you need to verify a package. To do this you can use the -Vp (verify package).
[root@eldernode downloads]# rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm S.5....T. c /etc/httpd/conf.d/sqlbuddy.conf
17- How To Verify all RPM Packages
Run the command below to verify all the installed rpm packages.
[root@eldernode]# rpm -Va S.5....T. c /etc/rc.d/rc.local .......T. c /etc/dnsmasq.conf .......T. /etc/ld.so.conf.d/kernel-2.6.32-279.5.2.el6.i686.conf S.5....T. c /etc/yum.conf S.5....T. c /etc/yum.repos.d/epel.repo
18- How To Import An RPM GPG key
You need to import the GPG key to verify RHEL/CentOS/Fedora packages. It will import CentOS 7 GPG key. So, run the following command to do this.
[root@eldernode]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
19- How To Check List all Imported RPM GPG keys
The below command lets you print all the imported GPG keys in your system.
[root@eldernode]# rpm -qa gpg-pubkey* gpg-pubkey-0608b895-4bd22942 gpg-pubkey-7fac5991-4615767f gpg-pubkey-0f2672c8-4cd950ee gpg-pubkey-c105b9de-4e0fd3a3 gpg-pubkey-00f97f56-467e318a gpg-pubkey-6b8d79e6-3f49313d gpg-pubkey-849c449f-4cb9df30
20- How To Rebuild Corrupted RPM Database
One of the most important things to consider when working with RPM packages is How to rebuild a corrupted RPM Database Which is discussed in the Tutorial Linux RPM command. To get ready for the situations that rpm database gets corrupted and stops all the functionality of rpm and other applications on the system, learn to rebuild the rpm database and restore it with the help of the following command.
[root@eldernode]# cd /var/lib [root@eldernode]# rm __db* [root@eldernode]# rpm --rebuilddb [root@eldernode]# rpmdb_verify Packages
Conclusion
In this article, you have learned 20 practical examples of Linux RPM Commands. In case you need to learn more commands, find our related article on A to Z Linux commands overview with examples.
How can i list all the commands i could run?
You can use the bash (1) built-in compgen
compgen -c will list all the commands you could run
Are commands case-sensitive?
Yes, Linux/Unix commands are case-sensitive. Additionally, Linux commands run in the terminal provided by Linux/Unix system.
Where is the alias command used for?
While executing the command alias would instruct the shell to replace one string with another string.
How could we see in which directory we are in?
When you first open the terminal, you are in the home directory of your user. To know which directory you are in, you can use the “pwd” command
Why should RPM be used?
It is used because it is a popular utility for installing software on Unix-like systems.