Usually, a user installs packages using the yum command line utility. The official CentOS repositories contain thousands of RPM packages, but in some cases, you may come across an RPM file that is not in any repository.
Some software authors provide only downloadable RPM files for installation, and that is why RPM files are designed to be downloaded and installed independently, outside of a software repository.
In this tutorial, we will learn how to install a .rpm file to your Linux CentOS distribution.
What is RPM package manager
Red Hat Package Manager is a free and open-source package management system for installing, uninstalling and managing software packages in Red Hat and its derivatives such as CentOS and Fedora.
Before we begin you need to ensure that you have sudo privileges and that you have installed on your system some of the RPM, DNF, & YUM Package Managers (all included by default).
Also, make sure the RPM package you want to install is built for your system architecture and your CentOS version.
For the purpose of this tutorial, we will be downloading and installing Slack RPM package on CentOS 8.
Download RPM installation package
For example, we will use wget command to download slack package (rpm) to the current directory (I am downloading to /tmp) as follows:
$ wget https://downloads.slack-edge.com/linux_releases/slack-4.3.2-0.1.fc21.x86_64.rpm --2020-02-15 23:11:20-- https://downloads.slack-edge.com/linux_releases/slack-4.3.2-0.1.fc21.x86_64.rpm Resolving downloads.slack-edge.com (downloads.slack-edge.com)... 126.96.36.199, 188.8.131.52, 184.108.40.206, ... Connecting to downloads.slack-edge.com (downloads.slack-edge.com)|220.127.116.11|: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]
To verify you can use ls command to list rpm file under '/tmp' directory:
$ ls /tmp/ slack-4.3.2-0.1.fc21.x86_64.rpm
Installing RPM file using RPM command
You can install RPM package using two methods. First is using RPM command, the other is using yum package manager.
In the following command we use
-i option to install the download rpm package:
$ sudo rpm -i /tmp/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 above output, we can see that the installation failed because of missing dependencies packages. So we have to check for rpm dependency packages and install them manually.
Check RPM dependencies
To check for the package dependencies we have two rpm options. You can use
-qpR to query rpm file and
-qR to query by package name.
rpm -qpR .rpm-file
rpm -qR package-name
For example, let's query a .rpm (we use slack rpm, which we already download before) file to find its all required dependency packages:
$ sudo rpm -qpR /tmp/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 libXScrnSaver libappindicator-gtk3 libsecret-1.so.0()(64bit) rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(PayloadIsXz) <= 5.2-1
Installing RPM packages with yum
Now comes the handy tool called
yum where we don't have to worry about dependencies. This yum package manager can pull all of the required dependencies and set them up for us.
We will now use yum package manager to install our downloaded package with the following command:
$ sudo yum localinstall /tmp/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 ====================================================================================== Installing: 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]:
y it will install all of the dependencies and our package:
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 Installed: slack-4.3.2-0.1.fc21.x86_64 Complete!
Removing RPM package
To remove the RPM package we instruct RPM to erase the software with
In the following example, we will uninstall (remove) slack package:
$ sudo rpm -e slack-4.3.2-0.1.fc21.x86_64
In this tutorial, we have shown you how to install and remove RPM packages on CentOS. You should prefer using yum over rpm as it automatically resolves all dependencies for you. Yum makes it simple to track installations, updates, and prerequisites.