Administration toolsCommands

How to Install RPM Packages on CentOS

The RPM Package Manager (RPM) is a powerful package management system used by Red Hat Linux and its derivatives such as CentOS and Fedora. RPM also refers to the rpm command and .rpm file format.
The official CentOS repositories contain thousands of RPM packages that can be installed using the yum or dmf; command-line utility. Packages that are not available in the standard CentOS repositories can be easily installed by enabling the appropriate repository.
But not all software vendors provide a yum repository for their application. Most often in, those situations, they will have a download page from where you can download and install the RPM package or download and compile the software from sources.
This guide will walk you through the process to install a .rpm file to your Linux CentOS or Fedora system.

Installing rpm Files with yum and dnf

yum and dnf are command-line tools for installing, updating, removing, and otherwise managing rpm packages on CentOS and related Linux distributions.
Starting from CentOS 8 dnf replaced yum as the default package manager. dnf is backward compatible with yum.
You can continue using yum on CentOS 8, as it is an alias for dnf. To install local rpm packages with yum or dnf, use the install command, followed by the path to the file.
In the example below we’re installing the Chrome Browser. First download Chrome Browser rmp file:

$ wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

Now install Chrome rpm package:

$ sudo yum install google-chrome-stable_current_x86_64.rpm
or
$ sudo dnf install google-chrome-stable_current_x86_64.rpm


Both yum and dnf will resolve and install all the package dependencies. You will be prompted to type Y to continue:
Example output

...
Install  69 Packages

Total size: 45 M
Total download size: 28 M
Installed size: 292 M
Is this ok [y/N]: 

That’s all, the application has been installed on your system, and you can start using it.
You can also install a rpm package directly from an URL:

$ sudo yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
or
$ sudo dnf install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

Installing RPM packages with rpm

rpm is a low-level tool that is used to install, uninstall, upgrade, query, and verify RPM packages.
To install an RPM package use the rpm -i command followed by the RPM package name:

$ sudo rpm -ivh google-chrome-stable_current_x86_64.rpm

The -v option tells rpm to show verbose output and -h to show the hash marked progress bar.
If the package depends on other packages that are not installed on the system, rpm will display a list of all missing dependencies. You will have to download and install all dependencies manually.
Instead of downloading and the installing the RPM package, you can use the URL to RPM package as an argument:

$ sudo rpm -ivh https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

To update a package, use the -U option:

$ sudo rpm -Uvh google-chrome-stable_current_x86_64.rpm

If the package you are trying to update is not installed, the rpm -U command will install it.
To install an RPM package without having all the required dependencies installed on the system, use the –nodeps option:

$ sudo rpm -Uvh --nodeps google-chrome-stable_current_x86_64.rpm

To remove (erase) a package use the rpm -e command, followed by the package name:

$ sudo rpm -e google-chrome-stable_current_x86_64.rpm

Conclusion

In CentOS, you can install a local rpm file using yum or dnf, in the same way as you would install a package from the repositories.
Feel free to leave a comment if you have any questions.

read also: Install PIP to manage python packages in linux

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button