All software on a Red Hat Enterprise Linux system is divided into RPM packages which can be installed, upgraded or removed.
The Red Hat Package Manager (RPM) is an open packaging system, which runs on Red Hat Enterprise Linux as well as other Linux and UNIX systems.
– Package installation is never interactive
– Applies to all SW [ core OS and add-ons ]
– No such thing as a patch to a package
RPM packages typically have file names like foo-1.0-1.i386.rpm. For example, Java rpm package name is jre-8u111-linux-i586.rpm. The file name includes the package name (foo, java), version (1.0, 8), release (1,u111), and architecture (i386,i586).
To install a package, log in as root and use the following command.
# rpm -Uvh jre-8u111-linux-i586.rpm
If the installation is successful, the following output is displayed
# rpm -Uvh jre-8u111-linux-i586.rpm Preparing... ############## [100%] 1:jre1.8.0_111 ############## [100%]
If a package of the same name and version is already installed, following output will be displayed
# rpm -Uvh jre-8u111-linux-i586.rpm Preparing... ############## [100%] package jre1.8.0_111-1.8.0_111-fcs.i586 is already installed
However, if you want to install the package anyway, you can use the –replacepkgs option or –force, which tells RPM to ignore the error.
# rpm -ivh --replacepkgs jre-8u111-linux-i586.rpm Preparing... ############## [100%] 1:jre1.8.0_111 ############## [100%]
# rpm -ivh jre-8u111-linux-i586.rpm --force Preparing... ############## [100%] 1:jre1.8.0_111 ############## [100%]
If you attempt to install a package that contains a file which has already been installed by another package, the following is displayed.
# rpm -Uvh foo-1.0-1.i386.rpm Preparing... ############## [100%] file /usr/bin/foo from install of foo-1.0-1 conflicts with file from package bar-2.0.20
To make RPM ignore this error, use the -replacefiles option
# rpm -ivh --replacefiles foo-1.0-1.i386.rpm
RPM packages may sometimes depend on other packages, which means that they require other packages to be installed to run properly. If you try to install a package which has an unresolved dependency, output similar to the following.
error: Failed dependencies: bar.so.2 is needed by foo-1.0-1 Suggested resolutions: bar-2.0.20-3.i386.rpm
If you are installing a package, it usually suggest the package(s) needed to resolve the dependency. Download suggested package(s) from Red Hat Network , and add it to the command.
# rpm -ivh foo-1.0-1.i386.rpm bar-2.0.20-3.i386.rpm
If installation of both packages is successful, output similar to the following is displayed
Preparing... ############## [100%] 1:foo ############## [100%] 2:bar ############## [100%]
If it does not suggest a package to resolve the dependency, you can try the -redhatprovides option to determine which package contains the required file. You need the rpmdb-redhat package installed to use this option.
# rpm -q --redhatprovides bar.so.2
If the package that contains bar.so.2 is in the installed database from the rpmdb-redhat package, the name of the package is displayed:
bar-2.0.20-3.i386.rpm
To force the installation anyway (which is not recommended since the package may not run correctly), use the -nodeps option.
# rpm -ivh foo-1.0-1.i386.rpm --nodeps
Uninstalling a package is just as simple as installing one. Use the following command.
# rpm -e jre1.8.0_111
Upgrading a package is similar to installing one. use the following command
# rpm -Uvh jre-8u111-linux-i586.rpm
As part of upgrading a package, RPM automatically uninstalls any old versions.
Note : -U will also install a package even when there are no previous versions of the package installed.
Freshening is similar to upgrading, except that only existent packages are upgraded, use the following command.
# rpm -Fvh jre-8u111-linux-i586.rpm
To query this database, use the -q option.
The rpm -q package name command displays the package name, version, and release number of the installed package package name.
For example, using rpm -q to query installed package jre1.8.0_111 might generate the following output:
# rpm -q jre1.8.0_111 jre1.8.0_111-1.8.0_111-fcs.i586
To check all the installed package on the system, use following command
# rpm -qa nautilus-sendto-2.28.2-3.el6.x86_64 plymouth-scripts-0.8.3-27.el6.x86_64 pinentry-gtk-0.7.6-6.el6.x86_64 dejavu-fonts-common-2.30-2.el6.noarch gedit-2.28.4-3.el6.x86_64 genisoimage-1.1.9-12.el6.x86_64 festvox-slt-arctic-hts-0.20061229-18.el6.noarch foomatic-db-filesystem-4.0-7.20091126.el6.noarch sound-juicer-2.28.1-6.el6.x86_64 urw-fonts-2.4-10.el6.noarc
To check whether a particular package is installed or not, use following command
# rpm -q jre1.8.0_111 jre1.8.0_111-1.8.0_111-fcs.i586
To check whether a package is consistent or not before installing it, use following command on shell prompt.
# rpm -ivh --test jre-8u111-linux-i586.rpm Preparing... ############## [100%]
To see the information about installed package, use below command
# rpm -qi jre1.8.0_111
To see the configuration files of the installed package, use following command
# rpm -qlc jre1.8.0_111
To see the directory with which a particular package is associated.
# rpm -qld jre1.8.0_111