{"id":11436,"date":"2019-03-14T07:30:53","date_gmt":"2019-03-14T07:30:53","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11436"},"modified":"2019-03-14T07:30:53","modified_gmt":"2019-03-14T07:30:53","slug":"20-practical-examples-of-rpm-commands-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/20-practical-examples-of-rpm-commands-in-linux\/","title":{"rendered":"20 Practical Examples of RPM Commands in Linux"},"content":{"rendered":"<p><strong>RPM<\/strong>\u00a0(<strong>Red Hat Package Manager<\/strong>) is an default open source and most popular package management utility for\u00a0<strong>Red Hat<\/strong>\u00a0based systems like (<strong>RHEL<\/strong>,\u00a0<strong>CentOS<\/strong>\u00a0and\u00a0<strong>Fedora<\/strong>). The tool allows system administrators and users to\u00a0<strong>install<\/strong>,\u00a0<strong>update<\/strong>,\u00a0<strong>uninstall<\/strong>,\u00a0<strong>query<\/strong>,\u00a0<strong>verify<\/strong>\u00a0and manage system software packages in\u00a0<strong>Unix\/Linux<\/strong>\u00a0operating systems. The RPM formerly known as\u00a0<strong>.rpm<\/strong>\u00a0file, that includes compiled software programs and libraries needed by the packages. This utility only works with packages that built on\u00a0<strong>.rpm<\/strong>\u00a0format.<\/p>\n<div id=\"attachment_1795\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/12\/RPM-Command-Examples.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1795\" title=\"RPM Command Examples\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/12\/RPM-Command-Examples-300x194.png\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/12\/RPM-Command-Examples-300x194.png 300w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/12\/RPM-Command-Examples.png 425w\" alt=\"RPM Command Examples\" width=\"300\" height=\"194\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">20 Most Useful RPM Command Examples<\/p>\n<\/div>\n<p>This article provides some useful\u00a0<strong>20 RPM command examples<\/strong>\u00a0that might be helpful to you. With the help of these rpm command you can managed to install, update, remove packages in your Linux systems.<\/p>\n<h3>Some Facts about RPM (RedHat Package Manager)<\/h3>\n<ol>\n<li>RPM is free and released under\u00a0<strong>GPL<\/strong>\u00a0(<strong>General Public License<\/strong>).<\/li>\n<li>RPM keeps the information of all the installed packages under\u00a0<strong>\/var\/lib\/rpm<\/strong>\u00a0database.<\/li>\n<li>RPM is the only way to install packages under Linux systems, if you\u2019ve installed packages using source code, then rpm won\u2019t manage it.<\/li>\n<li>RPM deals with\u00a0<strong>.rpm<\/strong>\u00a0files, which contains the actual information about the packages such as:\u00a0<strong>what it is<\/strong>,\u00a0<strong>from where it comes<\/strong>,\u00a0<strong>dependencies info<\/strong>,\u00a0<strong>version info<\/strong>\u00a0etc.<\/li>\n<\/ol>\n<h3>There are five basic modes for RPM command<\/h3>\n<ol>\n<li><strong>Install<\/strong>\u00a0: It is used to install any RPM package.<\/li>\n<li><strong>Remove<\/strong>\u00a0: It is used to erase, remove or un-install any RPM package.<\/li>\n<li><strong>Upgrade<\/strong>\u00a0: It is used to update the existing RPM package.<\/li>\n<li><strong>Verify<\/strong>\u00a0: It is used to verify an RPM packages.<\/li>\n<li><strong>Query<\/strong>\u00a0: It is used query any RPM package.<\/li>\n<\/ol>\n<h3>Where to find RPM packages<\/h3>\n<p>Below is the list of rpm sites, where you can find and download all\u00a0<strong>RPM<\/strong>\u00a0packages.<\/p>\n<ol>\n<li><a href=\"https:\/\/rpmfind.net\/\" target=\"_blank\" rel=\"nofollow noopener\">http:\/\/rpmfind.net<\/a><\/li>\n<li><a href=\"https:\/\/www.redhat.com\/\" target=\"_blank\" rel=\"nofollow noopener\">http:\/\/www.redhat.com<\/a><\/li>\n<li><a href=\"http:\/\/freshrpms.net\/\" target=\"_blank\" rel=\"nofollow noopener\">http:\/\/freshrpms.net\/<\/a><\/li>\n<li><a href=\"http:\/\/rpm.pbone.net\/\" target=\"_blank\" rel=\"nofollow noopener\">http:\/\/rpm.pbone.net\/<\/a><\/li>\n<\/ol>\n<p><strong>Read Also :<\/strong><\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement\/\" target=\"_blank\" rel=\"noopener\">20 YUM Command Examples in Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/10-wget-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">10 Wget Command Examples in Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/useful-linux-commands-for-system-administrators\/\" target=\"_blank\" rel=\"noopener\">30 Most Useful Linux Commands for System Administrators<\/a><\/li>\n<\/ol>\n<p>Please remember you must be\u00a0<strong>root<\/strong>\u00a0user when installing packages in Linux, with the root privileges you can manage rpm commands with their appropriate options.<\/p>\n<h3>1. How to Check an RPM Signature Package<\/h3>\n<p>Always check the PGP signature of packages before installing them on your Linux systems and make sure its integrity and origin is\u00a0<strong>OK<\/strong>. Use the following command with\u00a0<strong>\u2013checksig<\/strong>\u00a0(<strong>check signature<\/strong>) option to check the signature of a package called\u00a0<strong>pidgin<\/strong>.<\/p>\n<pre>[root@tecmint]# rpm --checksig pidgin-2.7.9-5.el6.2.i686.rpm\r\n\r\npidgin-2.7.9-5.el6.2.i686.rpm: rsa sha1 (md5) pgp md5 OK<\/pre>\n<h3>2. How to Install an RPM Package<\/h3>\n<p>For installing an rpm software package, use the following command with\u00a0<strong>-i<\/strong>\u00a0option. For example, to install an rpm package called\u00a0<strong>pidgin-2.7.9-5.el6.2.i686.rpm<\/strong>.<\/p>\n<pre>[root@tecmint]# rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm\r\n\r\nPreparing...                ########################################### [100%]\r\n   1:pidgin                 ########################################### [100%]<\/pre>\n<h5>RPM command and options<\/h5>\n<ol>\n<li><strong>-i<\/strong>\u00a0: install a package<\/li>\n<li><strong>-v<\/strong>\u00a0: verbose for a nicer display<\/li>\n<li><strong>-h<\/strong>: print hash marks as the package archive is unpacked.<\/li>\n<\/ol>\n<h3>3. How to check dependencies of RPM Package before Installing<\/h3>\n<p>Let\u2019s say you would like to do a dependency check before installing or upgrading a package. For example, use the following command to check the dependencies of\u00a0<strong>BitTorrent-5.2.2-1-Python2.4.noarch.rpm<\/strong>\u00a0package. It will display the list of dependencies of package.<\/p>\n<pre>[root@tecmint]# rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm\r\n\r\n\/usr\/bin\/python2.4\r\npython &gt;= 2.3\r\npython(abi) = 2.4\r\npython-crypto &gt;= 2.0\r\npython-psyco\r\npython-twisted &gt;= 2.0\r\npython-zopeinterface\r\nrpmlib(CompressedFileNames) = 2.6<\/pre>\n<h5>RPM command and options<\/h5>\n<ol>\n<li><strong>-q<\/strong>\u00a0: Query a package<\/li>\n<li><strong>-p<\/strong>\u00a0: List capabilities this package provides.<\/li>\n<li><strong>-R<\/strong>: List capabilities on which this package depends..<\/li>\n<\/ol>\n<h3>4. How to Install a RPM Package Without Dependencies<\/h3>\n<p>If you know that all needed packages are already installed and RPM is just being stupid, you can ignore those dependencies by using the option\u00a0<strong>\u2013nodeps<\/strong>\u00a0(<strong>no dependencies check<\/strong>) before installing the package.<\/p>\n<pre>[root@tecmint]# rpm -ivh --nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm\r\n\r\nPreparing...                ########################################### [100%]\r\n   1:BitTorrent             ########################################### [100%]<\/pre>\n<p>The above command forcefully install rpm package by ignoring dependencies errors, but if those dependency files are missing, then the program will not work at all, until you install them.<\/p>\n<h3>5. How to check an Installed RPM Package<\/h3>\n<p>Using\u00a0<strong>-q<\/strong>\u00a0option with package name, will show whether an rpm installed or not.<\/p>\n<pre>[root@tecmint]# rpm -q BitTorrent\r\n\r\nBitTorrent-5.2.2-1.noarch<\/pre>\n<h3>6. How to List all files of an installed RPM package<\/h3>\n<p>To view all the files of an installed rpm packages, use the\u00a0<strong>-ql<\/strong>\u00a0(<strong>query list<\/strong>) with rpm command.<\/p>\n<pre>[root@tecmint]# rpm -ql BitTorrent\r\n\r\n\/usr\/bin\/bittorrent\r\n\/usr\/bin\/bittorrent-console\r\n\/usr\/bin\/bittorrent-curses\r\n\/usr\/bin\/bittorrent-tracker\r\n\/usr\/bin\/changetracker-console\r\n\/usr\/bin\/launchmany-console\r\n\/usr\/bin\/launchmany-curses\r\n\/usr\/bin\/maketorrent\r\n\/usr\/bin\/maketorrent-console\r\n\/usr\/bin\/torrentinfo-console<\/pre>\n<h3>7. How to List Recently Installed RPM Packages<\/h3>\n<p>Use the following rpm command with\u00a0<strong>-qa<\/strong>\u00a0(<strong>query all<\/strong>) option, will list all the recently installed rpm packages.<\/p>\n<pre>[root@tecmint]# rpm -qa --last\r\n\r\nBitTorrent-5.2.2-1.noarch                     Tue 04 Dec 2012 05:14:06 PM BDT\r\npidgin-2.7.9-5.el6.2.i686                     Tue 04 Dec 2012 05:13:51 PM BDT\r\ncyrus-sasl-devel-2.1.23-13.el6_3.1.i686       Tue 04 Dec 2012 04:43:06 PM BDT\r\ncyrus-sasl-2.1.23-13.el6_3.1.i686             Tue 04 Dec 2012 04:43:05 PM BDT\r\ncyrus-sasl-md5-2.1.23-13.el6_3.1.i686         Tue 04 Dec 2012 04:43:04 PM BDT\r\ncyrus-sasl-plain-2.1.23-13.el6_3.1.i686       Tue 04 Dec 2012 04:43:03 PM BDT<\/pre>\n<h3>8. How to List All Installed RPM Packages<\/h3>\n<p>Type the following command to print the all the names of installed packages on your Linux system.<\/p>\n<pre>[root@tecmint]# rpm -qa\r\n\r\ninitscripts-9.03.31-2.el6.centos.i686\r\npolkit-desktop-policy-0.96-2.el6_0.1.noarch\r\nthunderbird-17.0-1.el6.remi.i686<\/pre>\n<h3>9. How to Upgrade a RPM Package<\/h3>\n<p>If we want to upgrade any RPM package \u201c<strong>\u2013U<\/strong>\u201d (<strong>upgrade<\/strong>) option will be used. One of the major advantages of using this option is that it will not only upgrade the latest version of any package, but it will also maintain the backup of the older package so that in case if the newer upgraded package does not run the previously installed package can be used again.<\/p>\n<pre>[root@tecmint]# rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm\r\nPreparing...                ########################################### [100%]\r\n   1:nx                     ########################################### [100%]<\/pre>\n<h3>10. How to Remove a RPM Package<\/h3>\n<p>To un-install an RPM package, for example we use the package name\u00a0<strong>nx<\/strong>, not the original package name\u00a0<strong>nx-3.5.0-2.el6.centos.i686.rpm<\/strong>. The\u00a0<strong>-e (erase)<\/strong>\u00a0option is used to remove package.<\/p>\n<pre>[root@tecmint]# rpm -evv nx<\/pre>\n<h3>11. How to Remove an RPM Package Without Dependencies<\/h3>\n<p>The\u00a0<strong>\u2013nodeps<\/strong>\u00a0(<strong>Do not check dependencies<\/strong>) option forcefully remove the rpm package from the system. But keep in mind removing particular package may break other working applications.<\/p>\n<pre>[root@tecmint]# rpm -ev --nodeps vsftpd<\/pre>\n<h3>12. How to Query a file that belongs which RPM Package<\/h3>\n<p>Let\u2019s say, you have list of files and you would like to find out which package belongs to these files. For example, the following command with\u00a0<strong>-qf<\/strong>\u00a0(<strong>query file<\/strong>) option will show you a file\u00a0<strong>\/usr\/bin\/htpasswd<\/strong>\u00a0is own by package\u00a0<strong>httpd-tools-2.2.15-15.el6.centos.1.i686<\/strong>.<\/p>\n<pre>[root@tecmint]# rpm -qf \/usr\/bin\/htpasswd\r\n\r\nhttpd-tools-2.2.15-15.el6.centos.1.i686<\/pre>\n<h3>13. How to Query a Information of Installed RPM Package<\/h3>\n<p>Let\u2019s say you have installed an rpm package and want to know the information about the package. The following\u00a0<strong>-qi<\/strong>\u00a0(<strong>query info<\/strong>) option will print the available information of the installed package.<\/p>\n<pre>[root@tecmint]# rpm -qi vsftpd\r\n\r\nName        : vsftpd\t\t\t\t   Relocations: (not relocatable)\r\nVersion     : 2.2.2\t\t\t\t   Vendor: CentOS\r\nRelease     : 11.el6\t\t\t\t   Build Date: Fri 22 Jun 2012 01:54:24 PM BDT\r\nInstall Date: Mon 17 Sep 2012 07:55:28 PM BDT      Build Host: c6b8.bsys.dev.centos.org\r\nGroup       : System Environment\/Daemons           Source RPM: vsftpd-2.2.2-11.el6.src.rpm\r\nSize        : 351932                               License: GPLv2 with exceptions\r\nSignature   : RSA\/SHA1, Mon 25 Jun 2012 04:07:34 AM BDT, Key ID 0946fca2c105b9de\r\nPackager    : CentOS BuildSystem &lt;http:\/\/bugs.centos.org&gt;\r\nURL         : http:\/\/vsftpd.beasts.org\/\r\nSummary     : Very Secure Ftp Daemon\r\nDescription :\r\nvsftpd is a Very Secure FTP daemon. It was written completely from\r\nscratch.<\/pre>\n<h3>14. Get the Information of RPM Package Before Installing<\/h3>\n<p>You have download a package from the internet and want to know the information of a package before installing. For example, the following option\u00a0<strong>-qip<\/strong>\u00a0(<strong>query info package<\/strong>) will print the information of a package\u00a0<a href=\"https:\/\/www.tecmint.com\/install-sql-buddy-a-web-based-mysql-administration-tool-for-rhel-centos-fedora\/\" target=\"_blank\" rel=\"noopener\">sqlbuddy<\/a>.<\/p>\n<pre>[root@tecmint]# rpm -qip sqlbuddy-1.3.3-1.noarch.rpm\r\n\r\nName        : sqlbuddy                     Relocations: (not relocatable)\r\nVersion     : 1.3.3                        Vendor: (none)\r\nRelease     : 1                            Build Date: Wed 02 Nov 2011 11:01:21 PM BDT\r\nInstall Date: (not installed)              Build Host: rpm.bar.baz\r\nGroup       : Applications\/Internet        Source RPM: sqlbuddy-1.3.3-1.src.rpm\r\nSize        : 1155804                      License: MIT\r\nSignature   : (none)\r\nPackager    : Erik M Jacobs\r\nURL         : http:\/\/www.sqlbuddy.com\/\r\nSummary     : SQL Buddy \u00e2 Web based MySQL administration\r\nDescription :\r\nSQLBuddy is a PHP script that allows for web-based MySQL administration.<\/pre>\n<h3>15. How to Query documentation of Installed RPM Package<\/h3>\n<p>To get the list of available documentation of an installed package, use the following command with option\u00a0<strong>-qdf<\/strong>(<strong>query document file<\/strong>) will display the manual pages related to\u00a0<a href=\"https:\/\/www.tecmint.com\/linux-performance-monitoring-with-vmstat-and-iostat-commands\/\" target=\"_blank\" rel=\"noopener\">vmstat<\/a>\u00a0package.<\/p>\n<pre>[root@tecmint]# rpm -qdf \/usr\/bin\/vmstat\r\n\r\n\/usr\/share\/doc\/procps-3.2.8\/BUGS\r\n\/usr\/share\/doc\/procps-3.2.8\/COPYING\r\n\/usr\/share\/doc\/procps-3.2.8\/COPYING.LIB\r\n\/usr\/share\/doc\/procps-3.2.8\/FAQ\r\n\/usr\/share\/doc\/procps-3.2.8\/NEWS\r\n\/usr\/share\/doc\/procps-3.2.8\/TODO<\/pre>\n<h3>16. How to Verify a RPM Package<\/h3>\n<p>Verifying a package compares information of installed files of the package against the rpm database. The\u00a0<strong>-Vp<\/strong>(<strong>verify package<\/strong>) is used to verify a package.<\/p>\n<pre>[root@tecmint downloads]# rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm\r\n\r\nS.5....T.  c \/etc\/httpd\/conf.d\/sqlbuddy.conf<\/pre>\n<h3>17. How to Verify all RPM Packages<\/h3>\n<p>Type the following command to verify all the installed rpm packages.<\/p>\n<pre>[root@tecmint]# rpm -Va\r\n\r\nS.5....T.  c \/etc\/rc.d\/rc.local\r\n.......T.  c \/etc\/dnsmasq.conf\r\n.......T.    \/etc\/ld.so.conf.d\/kernel-2.6.32-279.5.2.el6.i686.conf\r\nS.5....T.  c \/etc\/yum.conf\r\nS.5....T.  c \/etc\/yum.repos.d\/epel.repo<\/pre>\n<h3>18. How to Import an RPM GPG key<\/h3>\n<p>To verify\u00a0<strong>RHEL\/CentOS\/Fedora<\/strong>\u00a0packages, you must import the\u00a0<strong>GPG<\/strong>\u00a0key. To do so, execute the following command. It will import<strong>\u00a0CentOS 6<\/strong>\u00a0GPG key.<\/p>\n<pre>[root@tecmint]# rpm --import \/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-CentOS-6<\/pre>\n<h3>19. How to List all Imported RPM GPG keys<\/h3>\n<p>To print all the imported\u00a0<strong>GPG<\/strong>\u00a0keys in your system, use the following command.<\/p>\n<pre>[root@tecmint]# rpm -qa gpg-pubkey*\r\n\r\ngpg-pubkey-0608b895-4bd22942\r\ngpg-pubkey-7fac5991-4615767f\r\ngpg-pubkey-0f2672c8-4cd950ee\r\ngpg-pubkey-c105b9de-4e0fd3a3\r\ngpg-pubkey-00f97f56-467e318a\r\ngpg-pubkey-6b8d79e6-3f49313d\r\ngpg-pubkey-849c449f-4cb9df30<\/pre>\n<h3>20. How To rebuild Corrupted RPM Database<\/h3>\n<p>Sometimes rpm database gets corrupted and stops all the functionality of rpm and other applications on the system. So, at the time we need to rebuild the rpm database and restore it with the help of following command.<\/p>\n<pre>[root@tecmint]# cd \/var\/lib\r\n[root@tecmint]# rm __db*\r\n[root@tecmint]# rpm --rebuilddb\r\n[root@tecmint]# rpmdb_verify Packages<\/pre>\n<p><a href=\"https:\/\/www.tecmint.com\/20-practical-examples-of-rpm-commands-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>RPM\u00a0(Red Hat Package Manager) is an default open source and most popular package management utility for\u00a0Red Hat\u00a0based systems like (RHEL,\u00a0CentOS\u00a0and\u00a0Fedora). The tool allows system administrators and users to\u00a0install,\u00a0update,\u00a0uninstall,\u00a0query,\u00a0verify\u00a0and manage system software packages in\u00a0Unix\/Linux\u00a0operating systems. The RPM formerly known as\u00a0.rpm\u00a0file, that includes compiled software programs and libraries needed by the packages. This utility only works with &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/20-practical-examples-of-rpm-commands-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;20 Practical Examples of RPM Commands in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11436","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11436"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11436\/revisions"}],"predecessor-version":[{"id":11437,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11436\/revisions\/11437"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}