How to install RPM on CentOS

Typically, users install packages using the yum command line utility. The official CentOS repository contains thousands of RPM packages, but in some cases you may encounter an RPM file that is not in any repository.

Some software authors only provide downloadable RPM files for installation, which is why RPM files are designed to be downloaded and installed independently of the software repository.

In this tutorial, we will learn how to install .rpm files to a Linux CentOS distribution.

What is RPM package manager

Red Hat Package Manager is a free open source package management system for installing, uninstalling, and managing packages in Red Hat and its derivatives such as CentOS and Fedora.


Before you start, you need to make sure you have sudo privileges and have some RPM, DNF and YUM package managers installed on your system (all included by default).

Also, make sure that the RPM package to be installed is built for your system architecture and CentOS version.

For the purposes of this tutorial, we will download and install the Slack RPM package on CentOS 8.

Download RPM installation package

Usually, a web browser is used to find and download the .rpm file, but you can also use command line tools such as wget or curl commands.

For example, we will use the wget command to download the slack package (rpm) to the current directory as follows:

$ wget
--2020-02-15 23:11:20--
Resolving (,,, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 60768380 (58M) [application/octet-stream]
Saving to: ‘slack-4.3.2-0.1.fc21.x86_64.rpm’

slack-4.3.2-0.1.fc21.x86_6 100%[========================================>]  57.95M   584KB/s    in 2m 19s  

2020-02-15 23:13:40 (427 KB/s) - ‘slack-4.3.2-0.1.fc21.x86_64.rpm’ saved [60768380/60768380]

Install RPM files using RPM commands

You can install RPM packages using two methods. The first is to use RPM commands and the other is to use the yum package manager.

In the following command, we use -i Option to install and download the rpm package:

$ sudo rpm -i ./slack-4.3.2-0.1.fc21.x86_64.rpm 
warning: ./slack-4.3.2-0.1.fc21.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 8e6c9578: NOKEY
error: Failed dependencies:
	libXScrnSaver is needed by slack-4.3.2-0.1.fc21.x86_64
	libappindicator-gtk3 is needed by slack-4.3.2-0.1.fc21.x86_64

From the output above, we can see that the installation failed due to a missing dependency package. Therefore, we have to check the rpm dependent packages and install them manually.

Check for RPM dependencies

To check package dependencies, we have two rpm options. you can use it -qpR Query the rpm file and -qR Query by package name.

rpm -qpR .rpm-file
rpm -qR package-name

For example, let’s query a .rpm (we use slack rpm) file to find all its required dependencies:

$ sudo rpm -qpR slack-4.3.2-0.1.fc21.x86_64.rpm
warning: slack-4.3.2-0.1.fc21.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 8e6c9578: NOKEY
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1

Install RPM packages using yum

Now appears named yum We don't have to worry about dependencies. This yum package manager can extract all required dependencies and set them for us.

Now we will use the yum package manager to install the downloaded package with the following command:

$ sudo yum localinstall ./slack-4.3.2-0.1.fc21.x86_64.rpm 
CentOS-8 - AppStream                                  6.4 kB/s | 4.3 kB     00:00    
CentOS-8 - Base                                       5.2 kB/s | 3.8 kB     00:00    
CentOS-8 - Extras                                     2.7 kB/s | 1.5 kB     00:00      
Extra Packages for Enterprise Linux Modular 8 - x86_6  26 kB/s |  27 kB     00:01    
Extra Packages for Enterprise Linux 8 - x86_64         20 kB/s |  29 kB     00:01    
Dependencies resolved.
 Package        Architecture    Version                   Repository             Size
 slack          x86_64          4.3.2-0.1.fc21            @commandline           58 M

Transaction Summary
Install  1 Package

Total size: 58 M
Installed size: 185 M
Is this ok [y/N]: 

After input y It will install all dependencies and our packages:

Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                              1/1 
  Installing       : slack-4.3.2-0.1.fc21.x86_64                                  1/1 
  Running scriptlet: slack-4.3.2-0.1.fc21.x86_64                                  1/1 
  Verifying        : slack-4.3.2-0.1.fc21.x86_64                                  1/1 



Remove RPM package

To remove the RPM package, we instruct RPM to remove the software using the following command -e Options.

In the following example, we will uninstall (remove) the slack package:

$ sudo rpm -e slack-4.3.2-0.1.fc21.x86_64

in conclusion

In this tutorial, we showed you how to install and remove RPM packages on CentOS. You should prefer to use yum over rpm as it will automatically resolve all dependencies for you. Yum makes it easy to track installations, updates and prerequisites.

Related Posts