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 that 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 .
To install RPM packages, you need to be logged in as a root or user with sudo privileges .
Usually, you would use a web browser to search and download an RPM file. Once you locate the file, you can download it using your browser or using a commandoline tool like curl
or wget
.
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 that you want to install:
wget https://example.com/file.rpm
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 are not currently installed, 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 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 file.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://example.com/file.rpm
To update a package, use the -U
option:
sudo rpm -Uvh file.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 file.rpm
To remove (erase) a package use the rpm -e
command, followed by the package name:
sudo rpm -e file.rpm
Conclusion
In this tutorial, we have shown you how to install RPM packages on CentOS. You should prefer using yum
over rpm
as it automatically resolves all dependencies for you.
If you have any questions or feedback, feel free to leave a comment.
Leave a Reply