Read in 3 minutes
How to Install RPM Packages on CentOS
RPM is a packaging system used by Red Hat and its derivatives such as CentOS and Fedora.
The official CentOS repositories contain thousands of RPM packages which can be installed using the yum 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.
In this tutorial, we will show you two methods of how to install RPM packages on CentOS.
Before you Begin
When installing RPM packages make sure they are built for your system architecture and your CentOS version.
You should avoid using this method to replace or update important system packages, like glibc, systemd, or other services and libraries that are essential for the proper functioning of your system. Doing this may lead to errors and system instability.
To install RPM packages you need to be logged in as a user with sudo privileges.
Installing RPM packages with YUM
Yum is the default package manager tool in CentOS. It is used to install, remove, download, query and update packages from the official CentOS repositories as well as other third-party repositories.
The first step is to download the RPM file you would like to install:
To install the package, use the
yum localinstall command followed by the path to the package name:
sudo yum localinstall file.rpm
Yum will prompt you for confirmation. Answer
y and the RPM package will be installed, assuming it’s compatible with your system and all dependencies are met.
If the RPM package depends on other packages that you do not have installed already, and if those packages are available in the repositories enabled on your system yum will install all dependencies. Otherwise,
yum will print a list of all the missing dependencies you will have to download and manually install those packages.
Instead of downloading and then installing the RPM package you can simply pass the URL to the RPM package to the
yum localinstall command:
sudo yum localinstall https://example.com/file.rpm
To update an RPM package that it is already installed with yum, use the same procedure as when installing the package.
If for some reason you want to remove the installed package use the standard
yum remove command followed by the package name:
sudo yum remove file.rpm
Installing RPM packages with RPM
RPM is a low-level tool that can be used to install, uninstall, and upgrade RPM packages.
To install an RPM package with the
rpm tool use the
-i option what stands for “install” followed by the RPM package name:
sudo rpm –ivh file.rpm
If the package depends on other packages that you do not have installed already, rpm will display a list of all missing dependencies. You will have to manually download and install all dependencies.
You can skip the downloading part and provide the RPM package URL to the
sudo rpm –ivh https://example.com/file.rpm
When updating a package with
rpm, use the
-U option which stands for “update”:
sudo rpm –Uvh file.rpm
To remove a package with the
rpm command use the
–e (erase) option followed by the package name:
sudo rpm –e file.rpm
In this tutorial, you learned how to install RPM packages on CentOS. You should prefer using the
rpm as it automatically resolves all dependencies for you.
If you have any question or feedback, feel free to leave a comment.