How To Install and Upgrade RPM Packages In CentOS, RHEL, Fedora, Mandriva
rpm is the package format used by popular distributions like RHEL, CentPOS, Fedora and Mandriva. We generally prefer to use
yum command to install packages from internet automatically and easily. In some cases we may need to install rpm packages solely. In this tutorial we will look how to solve dependency and install rpm package.
Download RPM Package
We can get RPM files from different sources. In the old days RPMs generally provided with CD or floppy disk but today internet is de facto source to get RPM files. We can use following sites to search and download RPM files for different distributions, architectures.
In this exmaple we will download RPM file with wget.
$ wget ftp://mirror.switch.ch/pool/4/mirror/centos/7.4.1708/updates/x86_64/Packages/iptables-utils-1.4.21-18.2.el7_4.x86_64.rpm
List RPM Package Dependencies
As we know packages generally requires some libraries and other packages to work accordingly. This is called package dependency. We should can list package dependencies to check whether the system met required packages.
$ rpm -qpR iptables-utils-1.4.21-18.2.el7_4.x86_64.rpm
As we can see there are some dependencies like libc, libnfnetlink etc.
Now we assume we have installed required dependencies and ready to install our downloaded RPM package. We will provide
-ivh options and the RPM package name to the
rpm command. We should also have root privileges where we can get with
sudo like below.
$ sudo rpm -ivh iptables-utils-1.4.21-18.2.el7_4.x86_64.rpm
Install Ignoring Dependencies
In some cases the system can not meet required dependencies but we should install package. May be the package can work without problem without some dependencies etc. We can install a package without dependencies with
--nodeps option like below.
$ sudo rpm -ivh --nodeps iptables-utils-1.4.21-18.2.el7_4.x86_64.rpm
Verify RPM Package Is Installed
After the installation is completed we can verify that the specified package is installed correctly. We can list installed RPM packages with
-qa option and then grep the the package we recently installed. In this example we check the
$ rpm -qa | grep iptables
If the package is all ready installed we should upgrade to preserve the existing package configuration. We can upgrade all ready installed RPM package with the new version with
-Uoption like below.
$ sudo rpm -Uvh iptables-utils-1.4.21-18.2.el7_4.x86_64.rpm