yum is an interactive, automated update program that can be used for maintaining systems using the RedHat Package Manager (RPM). It's a good thing.
Several years ago, just before Fedora Core 1 was released, there was something commonly referred to as "Dependency Hell" in RedHat Linux distributions. In the RedHat world, the installation of most new programs can be performed by rpm (unless you compile it yourself). If life is good, all you have to do is download the appropriate .rpm file for the application you wish to install, use rpm to install it on the system, and off you go. The advantage of rpm (yes, it is an advantage!) is that it automatically checks for dependencies — libraries and other files that the program needs — before actually allowing you install it. Theoretically, it's a great concept.
If life isn't quite so good, rpm tells you that there is a dependency missing and refuses to install the program. So off you go, hunting the web for another program that will provide the missing dependency. Once found, the dependency is installed first, followed by the desired program.
If your life is spiraling out of control, the dependency you are looking for requires another dependency, which requires its own dependency, and two more dependencies after that, and so on and so forth. Sometimes, you will also find that Dependency A depends upon Dependency B, which depends upon Dependency C, which depends on Dependency A — the lovable circular dependency problem. There is a method to the madness, however, because rpm can install all of the programs at once (thereby satisfying circular dependencies), but even so. If you've ever gone through it, you'll know that it gets to be hellish (even if you have read the manual), partly because there are times when you just can't find the dependency that you're looking for.
With yum, "Dependency Hell" is more or less a thing of the past (despite all of the FUD that is still thrown around about it — especially by the Slashdot crowd...). Basically, yum acts as a front end to rpm by automatically downloading all necessary dependencies for you (assuming it can find them) and then installs each of the dependencies in the correct order, followed by your desired program. yum does this by looking for programs and dependencies within central repositories (or through repository mirrors) such as the Fedora repository, which is now integrated with Fedora Extras as of Fedora 7. Secondary repository sources can also be added from other locations by creating an appropriate .repo file in /etc/yum.repos.d/ (this is covered in the Repositories & Updates page).
At any rate, there are a few useful programs that can be installed by yum in Fedora Extras that make life even more useful:
yumex - yumex,
or
yum extender, is a graphical user interface (GUI) for yum.
Sometimes its nice to browse through all of the programs that are
present in a repository, or to narrow down the list or programs by
performing a search. yumex
allows you to do so. It's a bit clunky, but it is still 10
times better than pirut
or pup,
which try (and fail miserably) to perform similar actions.
yum-fastestmirror
- The
yum-fastestmirror
plugin sorts each repository's mirrorlist by connection speed
prior to
downloading packages, and will choose the fastest mirror whenever yum is used.
I find it to be very useful.
yum-refresh-updatesd -
Tell yum-updatesd to refresh itself via dbus
yum-utils - yum-utils
is a collection of utilities and plugins that provide additional
flexibility when using yum. The
utilities include package-cleanup,
repoclosure,
repomanage,
repoquery,
repo-rss,
yum-builddep,
and yumdownloader. I
find package-cleanup
to be the most useful, as it checks for unneeded packages and
dependency problems, and will also remove old kernels from the system,
if needed.
Installing GPG Keys
To get a feel for yum, let's install each of the programs. The first thing is to verify and/or install the General Public Key (GPG key) for fedora-updates and fedora-extras, since rpm uses internal package signature checking for security. This means that all downloaded .rpm files are checked for a signed digital key in order to verify their authenticity. To see which keys have been imported:
~> rpm
-q gpg-pubkey
You
should see keys such as:fedora-updates:
gpg-pubkey-57bbccba-4a6f97af
gpg-pubkey-f8f5f58a-4756551d
gpg-pubkey-f6777c67-45e5b1b9
gpg-pubkey-7fac5991-4615767f
gpg-pubkey-16ca1a56-4a100959
gpg-pubkey-a3a882c1-4a1009ef
gpg-pubkey-f8f5f58a-4756551d
gpg-pubkey-f6777c67-45e5b1b9
gpg-pubkey-7fac5991-4615767f
gpg-pubkey-16ca1a56-4a100959
gpg-pubkey-a3a882c1-4a1009ef
If a particular key is missing, you can import it:
~>
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
Then
check again to verify
that the key has been successfully imported.If you make a mistake and accidentally import a key more than once, you can delete all matches of the key using the following command:
~>
sudo rpm -e
gpg-pubkey-[]-[] --allmatches
Once
executed, you will have to re-import the appropriate GPG key
since
all matches to the key will be removed from the system.Installing packages with yum
With that done, we are ready to install the programs with yum:
~>
sudo yum install yumex yum-fastestmirror yum-refresh-updatesd yum-utils
After
hitting Enter,
yum
will search through the configured repositories and look
for packages. (If you are asked to install additional
pgp-pubkeys,
allow the system to do so.) Since they are all located in Fedora Extras,
once found, yum
will download the header information for each of the programs, followed
by a transaction test to resolve
any dependencies. You will
then be prompted to confirm the installation. After
hitting "y",
the .rpm
files for each of the programs (and dependencies) will be downloaded,
and then installed automatically using rpm.If you do not wish provide confirmation to the process each time you install a program, you may use the "-y" option:
~>
sudo yum -y install yumex
yum-fastestmirror
yum-refresh-updatesd yum-utils
This
will assume that the answer to any question asked by yum is "yes". See the
man
page for additional details.With that, the yumex, yum-fastestmirror, etc. packages have now been installed. yumex can be run from the command prompt, and the aforementioned utilities (such as package-cleanup) are now a part of the system. As an example, yum-fastestmirror will automatically be used by yum each time it is run.
Removing packages with yum
If you want to remove a package:
~>
sudo yum remove totem-mozplugin
Press "y"
when asked
if you want to remove any additional dependencies.Using yum update
yum also comes with the wonderful "update" feature, which will search the repositories for any updated packages for your system.
~>
sudo yum update
The
first time you run this, it will
probably take a while, unless you've installed Fedora from a Re-Spin. If a new kernel is
installed, reboot the computer once finished.If you only wish to check for the existence of possible updates, you may use:
~>
sudo yum check-update
Running yum as a cron jobBy default, F12 uses the yum-updatesd daemon to tell the user when updates are available; the user can then manually download and install them. You can also set the "do_update" parameter in /etc/yum/yum-updatesd.conf to allow yum to automatically install the updates for you (which I am now doing).
Alternatively, you can also run yum as a cron job on a daily basis. To create your own yum cron job, stop the daemon and prevent it from re-starting:
~>
sudo service yum-updatesd stop
~> sudo yum-updatesd off
Then create an /etc/cron.daily/yum
file with the following information:~> sudo yum-updatesd off
#!/bin/sh
yum -y update | /bin/mail -s "Daily yum Update Report" root@[host].[local].[domain]
exit 0
Save and exit.
Then make the file executable:yum -y update | /bin/mail -s "Daily yum Update Report" root@[host].[local].[domain]
exit 0
~>
sudo chmod ugo+x yum
It is also wise
to clean the old yum
header files occasionally with a monthly cron job.
Create an /etc/cron.monthly/yum
file with the following information:#!/bin/sh
yum clean all
Save and exit.
Then make the file executable:yum clean all
~>
sudo chmod ugo+x yum
As
a final note, sometimes there is a troublesome
package in one of the repositories that was either put there by
mistake, or because one of the maintainers wasn't thinking
properly and allowed a buggy package to slip through the
cracks. In this case, it may be necessary to disable the
installation or
upgrade of a particular package for a few days if the dependency cannot
be resolved, or if there is another problem. This can be done
with the "--exclude=[package]" option. Entire repositories can
also be excluded using the "--disablerepo=[repository]" option. yum
still needs a bit of hand holding from time
to time, but it is well worth the effort.


