This article provides an overview of the
rpm
and yum
commands for installing software packages on Linux. rpm
Therpm
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.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.# 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 "-q" option allows you to query installed packages. You can then erase specific packages using the "-e" option.# 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 big limitation of the# 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 #
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
Theyum
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
Next, you can do one of two things.# 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
- Use the DVD directly as a Yum repository.
- Create a new Yum repository by copying the packages off the DVD.
Import the GPG key from the DVD.[dvd] name=Oracle Linux Installation DVD baseurl=file:///media/cdrom enabled=0
You can now use the DVD as a Yum repository by referencing it using the "--enablerepo" option.# rpm --import /media/cdrom/RPM-GPG-KEY
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.# yum install --enablerepo=dvd system-config-lvm
To create a repository, we need to install the# mkdir /repo # cp /media/cdrom/Packages/* /repo
createrepo
package, which requires a couple of dependencies.Now we can create a repository out of the contents of the directory.# cd /repo # rpm -ivh deltarpm* python-deltarpm* # rpm -ivh createrepo*
To allow the# cd /repo # createrepo .
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.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.[localrepo] name=localrepo baseurl=file:///repo/ enabled=1 gpgcheck=0
When using internet repositories, you typically expect the "gpgkey" entry as a security precaution.baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/2/base/$basearch/ gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
You should now be able to use the
yum
command to install packages.yum
Theyum
command allows you to install, update, list and remove packages.The advantage of# yum install system-config-lvm # yum update system-config-lvm # yum list system-config-lvm # yum remove system-config-lvm
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.
You can install, update or remove entire groups of packages as follows.# yum grouplist
# 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.Kernel Updates
Updating the kernel on a system is simple using theyum
command. Simply issue the following command and the kernel and all its dependencies will be updated.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.# yum update kernel
No comments: