Выбрать главу

Maintaining yum

Over time yum can build up a large cache of RPM headers and other assorted information that can gradually build up to occupy a sizable amount of room on your hard drive. This cache is kept in /var/cache/yum, and you can manage it by using the yum command with your choice of options.

After yum finishes with the packages it downloads, it does not automatically delete them from the system, even though you might have no further use for them. After only one invocation of yum update, I found that my cache file had blossomed to just over 500MB in size. A few months down the line and this could grow exponentially as new updates, bug fixes, and security patches become available.

As with all things in Fedora, you get a choice as to what you want to remove: the pack ages themselves, the RPM header files, or both. To clean the system of just the packages, use the following command:

# yum clean packages

When I did this, yum removed all the downloaded packages on my system, saving me 450MB immediately.

If you also want to remove the header files, you can use the following command:

# yum clean headers

This saved an extra 10MB on top of the 450MB that removing the packages gave me.

NOTE

If you decide to remove the header files, yum has to re-download them the next time that you decide to update your system. This can take a little bit of time, but should not be a problem if you have a fast broadband connection.

Finally, if you want to remove both the packages and the headers in one quick step, you should use this command:

# yum clean all

This removes all packages and headers from the cache. We suggest using the command just to clean the packages, especially if you are on a slow Internet connection, because keeping the headers saves you time in future updating sessions.

Using yum to Manage Package Inventory

Another useful feature of yum is its capability to list several sets of packages. There are a few options that you can list, including packages that are currently installed, packages that are available to be installed, and packages that have updates available.

The command is as follows:

$ yum list <available> <updates> <installed> <extras>

► available — This lists the available packages in the configured repositories.

► updates — This lists the available updates for currently installed packages.

► installed — This lists the packages currently installed on the system.

► extras — This lists the installed packages that are not present in any of the configured repositories.

So if I want to find out which packages I have installed on my system, I use the command yum list installed to return a detailed summary of packages installed and their version numbers. You can take this one step further and query for individual pack ages. You might want to find out which version of OpenOffice.org you have installed and which version is available for installation. For this, you use yum list openoffice.org — the results of which would show you which version was installed and which version was available for updating.

yum can also search the headers and summaries for each RPM file so that you can find specific information about packages that would not usually be available in just the package name itself. For example, using yum search kdebindings would bring up entries matching kdebindings. The results of this command are shown here:

$ yum search kdebindings

Loading "refresh-updatesd" plugin

kdebindings-devel.i386 : Development files for kdebindings

kdebindings-dcopperl.i386 : DCOP Bindings for Perl

kdebindings-devel.i386 : Development files for kdebindings

kdebindings.i386 : KDE bindings to non-C++ languages

kdebindings-dcopperl.i386 : DCOP Bindings for Perl

kdebindings.i386 : KDE bindings to non-C++ languages

Configuring yum

As mentioned earlier, yum is primarily controlled by the contents of the yum.conf file and the /etc/yum.repos.d directory. Let's take a closer look at the contents of both of these so that you can get a better understanding of how best to configure yum.

When you initially install Fedora, a default yum.conf file provides several switches for the yum command. It basically saves you from having to type in a number of switches and keeps yum simple. By default, yum is configured to do the following:

► Keep a cache of headers in /var/cache/yum

► Give minimal onscreen information during processing

► Keep a log file in /var/log/yum.log

► Download only the most up-to-date packages

► Be tolerant of errors in the process

► Match packages to your processor architecture

► Have a maximum retry limit of 20 times

► Check for obsolete packages

► Use GPG keys to ensure the identities of packages

All these options are contained within the yum.conf file, letting you easily modify or even remove certain lines. For instance, you might need yum to try only a maximum of five times, or you might need yum to give you more visual information.

You can add repository information into the yum.conf file, but an easier way to handle repos is to use the /etc/yum.repos.d folder. This folder enables you to create individual configuration files for each repository. By default, Fedora comes with repositories for their base packages, updated packages, updated packages that are in testing, and the more unstable development packages. Only the base and updated packages are enabled by default.

CAUTION

Unless you really know what you are doing, avoid the more unstable repositories of fedora-updates-testing and fedora-development. These repositories contain bleeding-edge packages that can break your system. You have been warned!

Opening a repository file shows you some details about the repository itself, including the path to it (either via HTTP, FTP, or local access), any lists of mirrors for that repository, whether that repository is enabled, and whether GPG checking is enabled.

If you want to add a new repository, you need to find out a few things before you can successfully add it to either its own repository file under /etc/yum.repos.d or in the yum.conf file.

You can also configure yum to ignore or exclude updates to certain packages. So, for instance, if you have a graphics driver that works only with a specific kernel version and you do not want to have to fix it every time a new kernel is released, you can elect for yum to exclude any kernel updates. Within the yum.conf file, you need to add a line within the top section similar to this: