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 CentOS repositories contain thousands of rpm packages that can be installed using the desktop software manager or from the command line using the yum, dnf, and rpm utilities. Some libraries and applications are packaged in rpm format but not included in any CentOS repository. Those applications have to be downloaded from the developer’s websites and installed manually.

In this tutorial, we will explain how to install rpm files on CentOS.

Be extra careful when installing rpm packages from unofficial sources. The package must be built for your system architecture and CentOS version. Never replace or update essential system packages, like glibc, systemd, or other services and libraries that are essential for the proper functioning of the system.

Only root or user with sudo privileges can install or remove RPM packages.

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:

sudo yum install google-chrome-stable_current_x86_64.rpm
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:

...
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
sudo dnf install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

Installing rpm Files with rpm

rpm is a low-level package manager for RHEL systems.

You should always prefer using yum or dnf over rpm when installing, updating, and removing packages as it doesn’t resolve dependencies.

To install rpm packages with rpm use the -i (or -U) option followed by the path to the file:

sudo rpm -i google-chrome-stable_current_x86_64.rpm

If the package you are installing or updating depends on other packages that are not currently installed, rpm will display a list of all missing dependencies. You will have to install all the dependencies.

rpm also accepts installing packages from an URL:

sudo rpm -i 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.