How to install or upgrade an RPM package?
Environment
- Red Hat Enterprise Linux 6, 7, 8, 9
Issue
- How to install or upgrade an RPM package ?
- How to upgrade
rpm
package ?
Resolution
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.
Examples:
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 thels
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 <package name>
. We can install the RPM package with the following command:rpm -ivh <package name>
. 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 thels
command. Then we will run an RPM query to see if the package we want to install exists in the RPM database,rpm -q <package name>
. Next, we execute the RPM installation with the following command:rpm -Uvh <package name>
. 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.
13 Comments
ok
expat-2.0.1-9.1.el6.i686.rpm
Where do I get the rpm files???
I would like to know this too. I'm working in an environment where automatic yum installs are blocked by firewalls. It is very difficult and time consuming to hunt down RPM files individually when the instructions always overlook this possibility and assume everyone can use the more automatic methods.
You can get all RPM files from following URL: https://access.redhat.com/downloads/content/69/ver=/rhel---7/7.0/x86_64/packages
The easiest way to get packages is from the installation DVD. ;) Another way is to subscribe your system and download the packages locally using:
or
or just
Looking for Public key for rhncfg-5.10.99-1.el5.noarch.rpm is not installed
I get warning user does not exist - using root, ######... 100%, but then it goes back to command prompt. Still at previous version.
This means the rpm expects a user that you do not have. Should be fixed by the rpm responsible, but usually these are warnings only (as far as you are still at previous version it might be an error).
I'm getting this on RHEL Atomic below error : Actually this is McAfee Agent root@ip-xxx-xxx-xxx tmp]# ./install.sh -i space required to copy archive is 69382392 bytes space available at mfeqDMuqI is 936361984 bytes extracting archive to mfeqDMuqI... please wait 67522+1 records in 67522+1 records out 34571397 bytes (35 MB) copied, 0.0689421 s, 501 MB/s Archive: mfeqDMuqI/package.zip inflating: mfeqDMuqI/MFEma.x86_64.rpm
inflating: mfeqDMuqI/MFErt.i686.rpm
inflating: mfeqDMuqI/MFEma.i686.rpm
inflating: mfeqDMuqI/MFEma.x86_64.deb
inflating: mfeqDMuqI/MFErt.i686.deb
inflating: mfeqDMuqI/MFEma.i686.deb
inflating: mfeqDMuqI/reqseckey.bin
inflating: mfeqDMuqI/srpubkey.bin
inflating: mfeqDMuqI/sitelist.xml
inflating: mfeqDMuqI/req2048seckey.bin
inflating: mfeqDMuqI/sr2048pubkey.bin
inflating: mfeqDMuqI/agentfipsmode
inflating: mfeqDMuqI/agent.ini
inflating: mfeqDMuqI/RepoKeys.ini
error: can't create transaction lock on /var/lib/rpm/.rpm.lock (No such file or directory) [root@ip-xxxxx-xxxx- tmp]#
I have installed Redhat linux package v6.7. When i run command "rpm -qa | grep redhat-release'. It returns "redhat-release-server-6Server_6.7.0.3_el6.x87_64"; I want to edit this result to "redhat-release-server-6.7.0.3_el6.x87_64". Can i edit some configuration file to update this?
No. This is the name-version-release.arch of the installed package. It is was defined in the .spec file used to build the package.
Hey!