Yum Revisited (Part 1)
This is a first of a series of two articles dedicated to the “yum” program. In this first article, we will mainly look at the configuration files. In the next article, we will look at some advance usage, that will help us in administrating our servers. As always, will build our article, in a way that we can come back to it and use it as a reference if we need some information about “yum”. We will concentrate on the command line version of “yum”, but I would like mention that there is a graphical version called “yumex” that I would recommend. It is not the fastest one, but it is simple to use and it work. Visit the “yumex” home page, you can aloso download the RedHat/Centos 5 rpm from here.
Main configuration file (/etc/yum.conf)
We can say that “yum” configuration break in two parts, the main configuration file yum.conf located in the /etc directory and the /etc/yum.repos.d directory that contains separated files for each repository that “yum” can connect to, for updating/installing our system. Below is a modified version of the yum.conf file that include comment for every option line, so we could use it as a reference. I think all options, along with the comments included are self explanatory .
# The Main section must exist for yum to do anything [main] # Directory where packages are downloaded cachedir=/var/cache/yum # 0=Remove packages & headers after they are install/update # 1=Keep downloaded packages after update keepcache=0 # Debug Level. Valid numbers are 0-10, default is 2 debuglevel=2 # Where yum log file is located logfile=/var/log/yum.log # Distribution Package Name (Fedora=fedora-release, RedHat/Centos=redhat-release) distroverpkg=redhat-release # 1=Complaint when package aleady install is installed, 0=not tolerant # For example, if you request to install foo, bar and baz and baz is installed; # yum won't error out complaining that baz is already installedt tolerant=1 # 1=Only update the architectures of packages that is installed, 0=Override Check exactarch=1 # Let yum determine if package is obsolete during update (1=Activate 0=Deactivate) obsoletes=1 # Confirms that all packages are cryptographically verified gpgcheck=1 # 1=Enabling yum plugins, 0=Disable yum plugins # Once plugins are enabled in yum.conf, you may install yum plugins and use them. plugins=1 # Determine when repositories metedata expire after it is received. # Note: yum-RHN-plugin doesn't honor this. metadata_expire=1h # Some package (like kernel) can only be install and not updated # So here we would keep 5 versions of the kernel. # When the sixth one is installed, the oldest one will get deleted. installonly_limit = 5 # List of packages to exclude from updates or installs. # Uncomment below if you want to autoupdate also the kernel rpms # Reboot is necessary to use the new kernel, once installed. # exclude=kernel* # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d #
Yum repository directory (/etc/yum.repos.d)
In the “/etc/yum.repos.d” directory, we will find one file for each repository we want to use to download or install packages. In a simple RedHat installation we will have one file, name “rhel-debuginfo.repo”. You can find the content and description of this file below. RedHat standard repository seems to be hidden or hard coded somewhere (check /etc/yum directory). Centos on the other side, have explicitly place 2 files in this directory (CentOS-Base.repo and CentOS-Media.repo), one for installing and updating our system from internet and the other one from CD/DVD.
# Section title - Can have multiple sections in the file [rhel-debuginfo] # Friendly name for the repository name=Red Hat Enterprise Linux $releasever - $basearch - Debug # Full URL to the packages (Can be http:// frp:// or file://) Baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/ # Activate(1) or De-Activate(0) the repository enable=1 # Enable(1)/Disable(0) - Packages cryptographic check gpgcheck=1 # GPG key used to verify RPM packages built and signed by Red Hat/Centos /Fedora gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
There are many additional repositories that we can subscribe for our RedHat/Centos/Fedora server. For example, there is the “Extra Packages for Enterprise Linux (EPEL)“, you can find the procedure for subscribing to it, but basically you download and install the RHEL4 and RHEL5 rpm. There is also the RPMforge repository where you will find packages for RedHat/Centos. Download the RedHat 5/Centos 5 rpm or the RedHat 4/Centos 4 rpm and follow the same procedure describe above for EPEL repository. There is also the DAG site and you can subscribe to the repository from this page.
Example, subscribing to EPEL RedHat 5 repository ;
GPG Repositories keys before subscribing root@rhel5:/etc/yum.repos.d# ls -l /etc/pki/rpm-gpg/ total 16 -rw-r--r-- 1 root root 1512 Mar 16 21:30 RPM-GPG-KEY-beta -rw-r--r-- 1 root root 1504 Mar 16 21:30 RPM-GPG-KEY-CentOS-5 Yum repository directory before root@rhel5:/etc/yum.repos.d# ls -l total 16 -rw-r--r-- 1 root root 2323 Mar 16 21:30 CentOS-Base.repo -rw-r--r-- 1 root root 626 Mar 16 21:30 CentOS-Media.repo root@rhel5:/etc/yum.repos.d# Subcribing to EPEL RedHat 5 repository # rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm Retrieving http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm warning: /var/tmp/rpm-xfer.hoNaf4: Header V3 DSA signature: NOKEY, key ID 217521f6 Preparing... ########################################### [100%] 1:epel-release ########################################### [100%] Yum repository directory after subscribing root@rhel5:/etc/yum.repos.d# ls -l total 24 -rw-r--r-- 1 root root 2323 Mar 16 21:30 CentOS-Base.repo -rw-r--r-- 1 root root 626 Mar 16 21:30 CentOS-Media.repo -rw-r--r-- 1 root root 954 Apr 25 2008 epel.repo -rw-r--r-- 1 root root 1054 Apr 25 2008 epel-testing.repo GPG Repositories keys after subscribing root@rhel5:/etc/yum.repos.d# ls -l /etc/pki/rpm-gpg/ total 20 -rw-r--r-- 1 root root 1512 Mar 16 21:30 RPM-GPG-KEY-beta -rw-r--r-- 1 root root 1504 Mar 16 21:30 RPM-GPG-KEY-CentOS-5 -rw-r--r-- 1 root root 1698 Apr 3 2007 RPM-GPG-KEY-EPEL root@rhel5:/etc/yum.repos.d#
Always be careful when you subscribe to a new repositories, you may encounter problem on some update afterward. If you do use additional repositories, I would suggest that you activate it to download the needed packages and then deactivate it by changing the line “enable=1″ to “enable=0″, in the proper file in /etc/yum.repos.d directory. If you ever need again, just activate the “enable” line.
In the next article, we will focus on the using the “yum” command itself, see you soon.

XHCWXB That’s 2 clever by half and 2×2 clever 4 me. Thanks!