Sunday, 5 December 2004

Package Management using YUM

RedHat and other RPM based Linux distributions contain one drawback over distributions like Debian in that it is very hard to upgrade or install softwares because of dependency issues. And where Debian Linux has a very efficient and clean package management tool in the apt-get package which automatically resolves the dependency issues, redhat/ rpm based distributions lacked this. That was until yum came along. Yum stands for Yellowdog Updater, Modified for Redhat based distributions which is the counterpart of apt-get for Debian. Yum automatically computes dependencies and figures out what steps need to occur in order to install packages. It makes it much easier to maintain groups of machines without having to manually update each one using rpm.



Here I will explain how to install, uninstall and update individual packages in your Redhat Linux system. Before you start using yum, you have to modify the configuration file /etc/yum.conf. This is because the redhat repository server is severely overloaded and might be very slow. So it is in our interests to look at third party repositories. Here I will use mirrors.kernel.org as the alternate repository. So my edited /etc/yum.conf file reflecting the change is as shown below:



#File /etc/yum.conf



[main]

cachedir=/var/cache/yum

debuglevel=2

logfile=/var/log/yum.log

pkgpolicy=newest

distroverpkg=redhat-release

tolerant=1

exactarch=1

retries=20



[base]

name=Fedora Core $releasever - $basearch - Base

#baseurl=http://download.fedora.redhat.com/pub/fedora/ Linux/core/$releasever/$basearch/os/

baseurl=http://mirrors.kernel.org/fedora/core/$releasever/ $basearch/os/



[updates-released]

name=Fedora Core $releasever - $basearch - Released Updates

#baseurl=http://download.fedora.redhat.com/pub/fedora/ Linux/core/updates/$releasever/$basearch/

baseurl=http://mirrors.kernel.org/fedora/core/updates/ $releasever/$basearch/

As you can see, I have commented out the redhat fedora repository server and added the mirrors.kernel.org repository.

Also add the following two lines to the /etc/sysconfig/rhn/sources file.

yum fedora-core-1 http://mirrors.kernel.org/fedora/core/1/i386/os

yum updates-released http://mirrors.kernel.org/fedora/core/updates/1/i386
This is only for using our choosen repository with other redhat updation tools like up2date and rpm tools which also come with Fedora core 1 and above. Now you are ready to use yum.



Updating the RPM headers
(This has to be done at least once the first time before you start using yum).

This downloads the header files of the RPM packages from the repositories to your machine and will take only a couple of minutes to complete.

# yum check-update
Update all the packages installed on your system

# yum update
Update just an individual package (say gedit):

# yum update gedit
In the above case, if the gedit package installed on your system is the current version, yum will not do anything.

Install a package (say rdesktop) for the first time:

# yum install rdesktop
Suppose you have a package (say mplayer) installed and you would like a GUI interface to it. But you do not have any idea what the package might be called. You can find it out using the following command :

# yum search mplayer gui
And this is what you might see:

Gathering header information file(s) from server(s)

Server: Fedora Core 1 - i386 - Base

Server: Fedora Core 1 - i386 - Released Updates

Finding updated packages

Downloading needed headers

Looking in available packages for a providing package

Available package: mplayer-frontend.i386 2:3.48-1 from base matches with Gtk+ frontend for mplayer.

Available package: mplayer-frontend.i386 2:3.48-1 from base matches with mplayer-frontend
From the above output, you come to know that 'mplayer gui' package is known by the name mplayer-frontend. Now you can install the package as explained earlier. The search option also accepts wild card characters in the event you need to utilize them.

If you need a certain library which is not a standalone package like say libc6.1-1.so.2 . Just use the following command to search in which package, the particular library is in:

# yum provides libc6.1-1.so.2
You might get the following output:

Gathering header information file(s) from server(s)

Server: Fedora Core 1 - i386 - Base

Server: Fedora Core 1 - i386 - Released Updates

Finding updated packages

Downloading needed headers

Looking in available packages for a providing package

Available package: compat-libstdc++.i386 0:7.3-2.96.118 from base matches with

libstdc++-libc6.1-1.so.2

Available package: compat-libstdc++.i386 0:7.3-2.96.118 from base matches with

libstdc++-libc6.1-1.so.2(GCC.INTERNAL)

2 results returned

Looking in installed packages for a providing package

No packages found

... which tells that the library is in the compat-libstdc++ package which can be installed using

# yum install compat-libstdc++
To remove a package (say gedit):

# yum remove gedit
This removes the selected package as well as any other package that depends on it.

One thing worth noting is that when Yum downloads packages or updates for installation it does not remove them automatically from its disk cache, so some periodic maintenance is required.This is achieved as follows:

# yum clean all
The above command deletes any old cached packages from your system as well as removing any old rpm headers that are no longer needed.

Lastly if you want to get any additional information about a package (say xchat) without actually installing it, do the following :

# yum info xchat
As you can see, it is a piece of cake in managing packages using yum. To know more about this wonderful package management software, you may visit official yum project page or do

$ man yum


No comments:

Post a Comment