- e Learning
- How to Install rpm Package in CentOS with yum install command
- Example – yum command to install rpm packages in CentOS 7
- How to Install an RPM File On Linux OS (CentOS, RHEL, & Fedora)
- Step 1: Download RPM Installation File
- Step 2: Install RPM File on Linux
- Install RPM File Using RPM Command
- Install RPM File with Yum
- Install RPM on Fedora
- Remove RPM Package
- Download RPM Packages from the Repository
- How to install or upgrade an RPM package?
- Installing or Upgrading
e Learning
How to Install rpm Package in CentOS with yum install command
In this tutorial we are going to learn how to install rpm Packages in CentOS 7 Linux using yum install command.
Traditionally the rpm command used to install rpm Packages in CentOS Linux. But the better way is to use yum command to install rpm files because when you install rpm package using yum command, it will automatically install all the dependency packages needs by the original package. With rpm command, we have to install all dependency packages manually one by one.
To install rpm package, use yum install command followed by the name of the rpm file you want to install.
If you do not specify the absolute path to the rpm file, yum command will look for the .rpm file in the current working directory or you can specify the absolute path to the .rpm file.
yum install /home/user/Download/filename.rpm
Example – yum command to install rpm packages in CentOS 7
For example, If I want to install teamviewer on CentOS 7, First, I download the teamviewer rpm installer, then install the rpm package with yum command.
yum install teamviewer_10.0.36281.i686.rpm
Same way, if you want to install google chrome on CentOS 7, First download the rpm package, then use yum command to install rpm package on Linux CentOS.
yum install google-chrome-stable_current_x86_64.rpm
So, that is how we can use yum command to install rpm packages in CentOS 7. You can use yum install command to install rpm packages on any RedHat Based Linux distribution, Including RHEL 7, Fedora and Oracle Linux.
How to Install an RPM File On Linux OS (CentOS, RHEL, & Fedora)
While working in Linux, you may have seen downloadable files with the .rpm extension. Rpm files are designed to be downloaded and installed independently, outside of a software repository.
This guide will show you how to install a .rpm file to your Linux CentOS or Fedora system.
Note: RPM Package Manager (RPM) is a free and open-source package management system for installing, uninstalling and managing software packages in Linux.
- A user account with sudo privileges
- Access to a terminal window / command line (Menu > applications > utilities > terminal, Ctrl-Alt-F2)
- RPM, DNF, & YUM Package Managers (all included by default)
Step 1: Download RPM Installation File
Typically, a web browser is used to locate and download a .rpm file. However, if a browser is not available you can still download a file if you know where it’s located.
You may need to install a software tool called wget .
To install wget in CentOS, enter the following in a terminal window:
To install wget in Fedora, enter the following:
Now, you can use the wget command to download the .rpm file you want. Enter the following:
wget http://some_website/sample_file.rpm
The system should reach out to the website and download the file to your current working directory.
Note: You can look up the address of a particular .rpm file in a web browser on another system. Also, this is a handy way to install more recent software versions or special non-standard software. Also, take care when installing software packages! Make sure you trust the source before you install. Usually, a developer will include a verification method to make sure you’re getting authentic software.
Step 2: Install RPM File on Linux
Install RPM File Using RPM Command
To install a .rpm package in CentOS Linux, enter the following:
sudo rpm -i sample_file.rpm
The -i switch tells the package manager you want to install the file.
More information on the RPM installer can be found in the RPM documentation.
Install RPM File with Yum
Alternately, you can use the yum package manager to install .rpm files.
sudo yum localinstall sample_file.rpm
The localinstall option instructions yum to look at your current working directory for the installation file.
Note: YUM stands for Yellowdog Updater Modified. Normally, yum looks to your enabled software repositories for new software packages to install. More recent verbiage suggests using install instead of localinstall, but it’s up to you.
Install RPM on Fedora
To install an .rpm package on Fedora Linux, enter the following:
sudo rpm -i sample_file.rpm
Just as in CentOS, the -i switch tells RPM to install the software.
Another method is to use the dnf utility to install the package:
sudo dnf localinstall sample_file.rpm
Unlike many Linux tools, DNF is not a set of initials. It is merely the next evolution of the yum package manager.
Remove RPM Package
The RPM installer can be used to remove (or uninstall) a software package.
Enter the following into a terminal window:
sudo rpm -e sample_file.rpm
The -e option instructs RPM to erase the software. Check RPM Dependencies
So far, this guide assumes the software either doesn’t have dependencies or already has them installed.
To check the .rpm file for dependencies using the following command:
sudo rpm -qpR sample_file.rpm
The system should list all the dependencies:
- -q – This option tells RPM to query the file
- -p – This option lets you specify the target package to query
- -R – This lists the requirements for the package
If there are any missing dependencies, you can install them from the standard repositories using yum or dnf. If your software requires other non-standard software, it will often be noted in the installation instructions.
Download RPM Packages from the Repository
One exciting feature of the yum package manager is that it allows you to download .rpm files directly from the repository. This might be helpful if you have limited bandwidth, or want to copy a single downloaded file between systems. It could also help if you have intermittent internet access, and you don’t want to spend time waiting for your installer to finish.
To download a .rpm file from the repositories, enter the following:
sudo yumdownloader packagename
If you wanted to download the files for Apache, for instance, you’d replace packagename with httpd. You can then install the file as above.
Note: In Linux, administrators find it helpful to have a single tool to manage software. That tool – called a package manager – can install software, keep track of software requirements, and track updates and patches. Package managers also work with repositories, which are secure and standardized libraries of commonly-used and well-supported applications. If you had to install wget in Step 1, that’s an example of installing from a repository.
In this tutorial, we covered three different options for installing RPM files on Linux.
As with most Linux software, your default package manager makes it simple to track installations, updates, and prerequisites.
How to install or upgrade an RPM package?
In order to install an RPM package you must first have the RPM package you are trying to install on your system. The Red Hat Customer Portal provides all the RPM packages included in our products in our Downloads area. There are two ways to locate a package you are interested in.
Browse by Package name
From Downloads, choose RPM Package Search. The Package Search allows searching for packages regardless of product, but can be limited to a specific product.
Browse By Product
From Downloads, browse to the product you are interested in and then select the ‘Packages’ tab. For example, packages for RHEL 7 Server
Note: An active product subscription that includes entitlements to the package are required to view or download packages.
For more information about downloading packages from the Customer Portal see this solution: How to download rpm package manually from the Customer Portal?
Installing or Upgrading
There are two main options of rpm command that are used to install or upgrade RPM packages:
- -i is used to install a new package. Always use this for kernel installations and upgrades just in case.
- -U is used to upgrade an RPM package but will also install a package if it does not exist in the RPM database.
Usage and additional options can be found in the RPM man page. Type man rpm from the command line. Here is some information about the -i and -U flags:
INSTALL AND UPGRADE OPTIONS The general form of an rpm install command is rpm <-i|--install>[install-options] PACKAGE_FILE . This installs a new package. The general form of an rpm upgrade command is rpm <-U|--upgrade>[install-options] PACKAGE_FILE . This install the package or upgrades the package currently installed to a newer version. This is the same as install, except all other version(s) of the package are removed after the new package is installed.
Note: These examples assume the packages are in a directory on your system. The below RPM commands are executed in the current working directory where the new RPM files reside.
- To install an RPM package, we use of the -i flag. As mentioned before, you use this flag when you are installing a kernel RPM. In this case, you will want to leave your old kernel in place, at least temporarily, in case the new kernel does not boot. In this example, we first check to see the names of the new RPM packages with the ls command. Then we query the RPM database to see which kernel packages are already installed. You do not need to include the version number in the query, but the usage is: rpm -q . We can install the RPM package with the following command: rpm -ivh . Note the -v option will show verbose output and the -h will show the hash marks, which represents action of the progress of the RPM upgrade. Lastly, we run another RPM query to verify the package will be available.
# ls kernel-2.4.21-15.0.3.EL.i686.rpm kernel-smp-2.4.21-15.0.3.EL.i686.rpm # rpm -q kernel; rpm -q kernel-smp kernel-2.4.21-4.0.1.EL kernel-2.4.21-15.0.2.EL kernel-smp-2.4.21-4.0.1.EL kernel-smp-2.4.21-15.0.2.EL # rpm -ivh kernel-2.4.21-15.0.3.EL.i686.rpm Preparing. ########################################### [100%] 1:kernel ########################################### [100%] # rpm -ivh kernel-smp-2.4.21-15.0.3.EL.i686.rpm Preparing. ########################################### [100%] 1:kernel-smp ########################################### [100%] # rpm -q kernel; rpm -q kernel-smp kernel-2.4.21-4.0.1.EL kernel-2.4.21-15.0.2.EL kernel-2.4.21-15.0.3.EL kernel-smp-2.4.21-4.0.1.EL kernel-smp-2.4.21-15.0.2.EL kernel-smp-2.4.21-15.0.3.EL
- To upgrade an RPM package, we use of the -U flag. In this example, we verify the new package name with the ls command. Then we will run an RPM query to see if the package we want to install exists in the RPM database, rpm -q . Next, we execute the RPM installation with the following command: rpm -Uvh . Note the -v option will show verbose output and the -h will show the hash marks, which represents action of the progress of the RPM upgrade. Lastly, we run another RPM query to verify the package will be available.
# ls httpd-2.0.46-32.ent.3.i386.rpm mod_ssl-2.0.46-32.ent.3.i386.rpm # rpm -q httpd; rpm -q mod_ssl httpd-2.0.46-32.ent mod_ssl-2.0.46-32.ent # rpm -Uvh httpd-2.0.46-32.ent.3.i386.rpm mod_ssl-2.0.46-32.ent.3.i386.rpm Preparing. ########################################### [100%] 1:httpd ########################################### [ 50%] 2:mod_ssl ########################################### [100%] # rpm -q httpd; rpm -q mod_ssl httpd-2.0.46-32.ent.3 mod_ssl-2.0.46-32.ent.3
Note: The httpd and mod_ssl needed to be installed at the same time because of dependency issues. If you try to install one without the other, you would get an error similar to the following:
# rpm -Uvh httpd-2.0.46-32.ent.3.i386.rpm error: Failed dependencies: httpd = 2.0.46-32.ent is needed by (installed) mod_ssl-2.0.46-32.ent
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.