Oracle 8i | Oracle 9i | Oracle 10g | Oracle 11g | Oracle 12c | Miscellaneous | PL/SQL | SQL | Oracle RAC | Oracle Apps | Linux

Installing Software Packages (rpm, yum)

This article provides an overview of the rpm and yum commands for installing software packages on Linux, with specific reference to the information needed for the RHCSA EX200 and RHCE EX300 certification exams.

Remember, the exams are hands-on, so it doesn't matter which method you use to achieve the result, so long as the end product is correct.

rpm

The rpm command is used to install, update, list and remove software packages. The command expects to be supplied with flags to indicate the mode of operation and one or more packages package files. Check out the man pages for a list of all the available options. Using the "-i" flag indicates you are attempting an install of one or more packages. The example below attempts to install a package from a CD. Notice wildcards are supported.

# cd /media/cdrom/Packages
# rpm -ivh system-config-lvm*
warning: system-config-lvm-1.1.12-9.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing...                ########################################### [100%]
   1:system-config-lvm      ########################################### [100%]
# 

The "-U" option uses the supplied packages to update the system. If a package already exists on the system, but the supplied package is newer it will be applied. If the package does not already exist on the system it will be installed.

# rpm -Uvh system-config-lvm*
warning: system-config-lvm-1.1.12-9.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing...                ########################################### [100%]
	package system-config-lvm-1.1.12-9.el6.noarch is already installed
#

The "-q" option allows you to query installed packages. You can then erase specific packages using the "-e" option.

# rpm -q system-config-lvm
system-config-lvm-1.1.12-9.el6.noarch
# rpm -e system-config-lvm-1.1.12-9.el6.noarch
#

The big limitation of the rpm command is it does not handle dependencies for you. If there are missing dependencies, an installation will fail. It is for this reason you will probably prefer to use the yum command described below.

yum Repositories

The yum command requires a repository as the source of the packages. If you are connected to the internet, you may choose to use the repository provided by your Linux distribution. In this case I am using Oracle Linux 6.x, so I could use the repository provided by Oracle (public-yum.oracle.com). If you have paid for RHEL support, you will register your server using the rhn_register command, which will configure a yum repository.

You can also create a local repository from a distribution DVD, CD or iso file. To do this you will need to mount the DVD, CD or iso file

# mkdir /media/cdrom

# # Mount physical/virtual cdrom/dvd
# mount /dev/cdrom /media/cdrom

# # Mount ISO image
# mount -o loop /path/to/disk1.iso /media/cdrom

Next, you can do one of two things.

To use the DVD directly, create a file called "/etc/yum.repos.d/dvd.repo" with the following contents, where the "baseurl" points to your DVD mount point.

[dvd]
name=Oracle Linux Installation DVD
baseurl=file:///media/cdrom
enabled=0

Import the GPG key from the DVD.

# rpm --import /media/cdrom/RPM-GPG-KEY

You can now use the DVD as a Yum repository by referencing it using the "--enablerepo" option.

# yum install --enablerepo=dvd system-config-lvm

If you want to take the second option and create a new Yum repository by copying the packages off the DVD, create a local directory to hold the yum repository and copy the packages to it.

# mkdir /repo
# cp /media/cdrom/Packages/* /repo

To create a repository, we need to install the createrepo package, which requires a couple of dependencies.

# cd /repo
# rpm -ivh deltarpm* python-deltarpm*
# rpm -ivh createrepo*

Now we can create a repository out of the contents of the directory.

# cd /repo
# createrepo .

To allow the yum command to use the repository, we must create a ".repo" file in the "/etc/yum.repos.d" directory. Create a file called "/etc/yum.repos.d/localrepo.repo" with the following contents.

[localrepo]
name=localrepo
baseurl=file:///repo/
enabled=1
gpgcheck=0

Notice the "baseurl" parameter. This indicates the location of the repository. In this case I am using a local file system, so the parameter is set to "file://" followed by the path to the repository "/repo/". If this were an internet repository we would expect a baseurl with a HTTP address. For example, the Oracle Linux repository setting would be as follows.

baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/2/base/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6

When using internet repositories, you typically expect the "gpgkey" entry as a security precaution.

You should now be able to use the yum command to install packages.

yum

The yum command allows you to install, update, list and remove packages.

# yum install system-config-lvm
# yum update system-config-lvm
# yum list system-config-lvm
# yum remove system-config-lvm

The advantage of yum over the rpm command is it deals with all dependencies for you, prompting you with the required dependencies and the total size of the operation. If you agree, all necessary dependencies will be installed, in addition to your specified package(s).

The main Linux distribution repositories also support package groups, allowing you to install, update or remove entire feature sets using a single command. To check if any groups have been defined in the repository, issue the following command.

# yum grouplist

You can install, update or remove entire groups of packages as follows.

# yum groupinstall "Development Libraries"
# yum groupupdate "Development Libraries"
# yum groupremove "Development Libraries"

GUI

The "Add/Remove Software" dialog is available from the console menu (System > Administration > Add/Remove Software). Provided you have yum repository available, you can use this tool to install individual packages or package groups.

Add/Remove Software

Kernel Updates

Updating the kernel on a system is simple using the yum command. Simply issue the following command and the kernel and all its dependencies will be updated.

# yum update kernel

The updated version of the kernel will be set as the default in the "/boot/grub/grub.conf" file, so next time the system is booted it will be used.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.