There are three ways to get a working /etc/yum.conf file. The best way is to get one ``automatically'' (or at worst, to have to pick one that matches your installation from a list of pre-built alternatives). If you're using yum from an RPM installed from a repository on your site (for example) it very likely is pre-configured with a /etc/yum.conf file that directs it to just the right campus or corporate or lab repositories.
Alternatively, there is a list of pre-built yum.conf entries for yummified
public repositories on the primary yum site:
Chances are pretty good that you can just grab one that matches your distribution (or that you'd like to upgrade to from your existing distribution) and install it. To use them, click on them and paste them into your yum.conf files as described next.
The last way is to build your yum.conf to meet your specific needs and support your own local repositories. This is the route that will almost certainly be taken by most systems administrators who build their own repository. To do this, start by reading the yum.conf man pages that should have come with your distribution. Look over the default /etc/yum.conf that was installed by the RPM. Finally, browse through the additional examples below. Chances are pretty good that one of these will resources will provide a template that is adequate to get you started, and once you get things running at all a bit of experimentation will soon make you an expert.
So let's look at a yum.conf file that is fairly minimal - just enough to get you started:
[main] cachedir=/var/cache/yum debuglevel=2 logfile=/var/log/yum.log [fedora-core] name = Fedora Core baseurl=http://www.myserver.org/fedora/ gpgcheck=1Systems persons who are building a fedora mirror as we proceed should note that this yum.conf uses the repository we ``built'' in the previous section, where of course the actual URL should point to that repository.
Users who want to accomplish the same thing could instead paste in an entry from the list of public yum repositories linked above. For example, here is a yum.conf file containing several repositories from that list:
[main] cachedir=/var/cache/yum debuglevel=2 logfile=/var/log/yum.log [fedora-stable-9] name=Fedora Project Stable RPMS for RHL 9 baseurl=http://download.fedora.us/fedora/redhat/9/i386/yum/stable/ gpgcheck=1 [fedora-updates-9] name=Fedora Project update RPMS for RHL 9 baseurl=http://download.fedora.us/fedora/redhat/9/i386/yum/updates/ gpgcheck=1
From the comments, one could hope that these two repositories contain what is effectively Red Hat 9, as ported into the Fedora project, plus updates. Note that we've turned on gpgcheck under the assumption that this is a good thing to do to ensure that the RPMs we grab haven't been trojanned.
Note that yum has many options that can be selected in the yum.conf file, only a few of which are illustrated in these examples. Each baseurl can have additional fallback repositories for additional stability and robustness. gpgchecking can be enabled (causing each rpm to be examined to ensure that it is correctly signed). The debuglevel can be cranked up or down to help diagnose problems. pkgpolicy can be set to determine the order in which yum chooses to decide between two versions of the same package on different repositories it is using at the same time. Packages can be listed to exclude them from the automated update process. The failover method yum uses to select a server to use from a list of servers in a baseurl can be chosen. More options may have been added since this article was written, or old options may have gone away.
So read the man pages on yum.conf. It is the only thing likely to be authoritative.
At this point we will assume that you are on a client, that you have a functional /etc/yum.conf installed that directs your system to a repository (that you built yourself or not) that is consistent with your system's existing RPM distribution, and that yum list works (as root) to list packages on the repository. Now let's see what yum can do.