4.3.2. Setting [repository] Options

The [repository] sections (where repository is a unique repository ID, such as my_personal_repo) allow you to define individual Yum repositories. To define a new repository, either add this section to the /etc/yum.conf file, or to a .repo file in the /etc/yum.repos.d/ directory.

All .repo files in /etc/yum.repos.d/are read by yum, which allows you to create new, custom .repo files in this directory. Best practice is to define your repositories here instead of in /etc/yum.conf.

The following is a (bare-minimum) example of the form a .repo file takes:

[repository_ID]
name=A Repository Name
baseurl=http://path/to/repo or ftp://path/to/repo or file:///path/to/local/repo

Every [repository] section must contain the following minimum directives:

[repository_ID]

The repository ID is a unique, one-word (no spaces; underscores are allowed) string of characters (enclosed by brackets) that serves as a repository identifier.

If the repository is local to the machine, use file:///path/to/local/repo

If a specific online repository requires basic HTTP authentication, you can specify your username and password in the http://path/to/repo by prepending it as username:password@link. For example, if a repository on http://www.example.com/repo/ requires a username of “user” and a password of “password”, then the baseurl link could be specified as:

baseurl=http://user:password@www.example.com/repo/

The following is another useful [repository] directive:

enabled=value

...where value is one of:

0 — do not include this repository as a package source when performing updates and installs. This is an easy way of quickly turning repositories on and off, which is useful when you desire a single package from a repository that you do not want to enable for updates or installs.

1 — include this repository as a package source.

Turning repositories on and off can also be performed by passing either the --enablerepo=repo_name or --disablerepo=repo_name option to yum, or through the Add/Remove Software window of the PackageKit utility.

Many more [repository] options exist. Refer to the [repository] OPTIONS section of man yum.conf for the exhaustive list and descriptions for each.