/etc/yum.repos.d/

The /etc/yum.repos.d/ directory contains repository configuration files for the YUM (Yellowdog Updater, Modified) package manager. Each file in this directory defines a repository that YUM can use to install and update software packages. These repository files are typically suffixed with .repo.

Structure of Repository Files

A typical repository file contains one or more sections, each corresponding to a different repository. Each section is identified by a repository ID enclosed in square brackets ([]). The sections contain key-value pairs that specify the repository's details and behavior.

Example Repository File

Here is an example of what a repository file, such as /etc/yum.repos.d/example.repo, might look like:

[example-repo]
name=Example Repository
baseurl=http://repo.example.com/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.example.com/RPM-GPG-KEY-example

Key Directives in Repository Files

  • name: A descriptive name for the repository.

    name=Example Repository
  • baseurl: The base URL where the repository's packages and metadata are located. It can include variables like $releasever and $basearch to make it dynamic.

    baseurl=http://repo.example.com/centos/$releasever/os/$basearch/
  • enabled: Determines whether the repository is enabled. 1 means the repository is enabled, and 0 means it is disabled.

    enabled=1
  • gpgcheck: Specifies whether GPG (GNU Privacy Guard) checking is performed on packages. 1 means GPG checking is enabled, and 0 means it is disabled.

    gpgcheck=1
  • gpgkey: URL to the GPG key file used for verifying the packages.

    gpgkey=http://repo.example.com/RPM-GPG-KEY-example

Additional Configuration Options

  • mirrorlist: URL to a file containing a list of base URLs for the repository. This can be used instead of baseurl.

    mirrorlist=http://mirrorlist.example.com/?repo=example-repo&arch=$basearch
  • priority: Assigns a priority to the repository when using the yum-plugin-priorities. Lower values mean higher priority.

    priority=1
  • exclude: Excludes specific packages from being installed or updated from this repository.

    exclude=package1 package2
  • includepkgs: Limits the repository to only include the specified packages.

    includepkgs=package1 package2

Managing Repositories

To add a new repository, create a new .repo file in the /etc/yum.repos.d/ directory with the appropriate configuration.

Adding a New Repository

For example, to add a new repository, create a file named /etc/yum.repos.d/newrepo.repo with the following content:

[newrepo]
name=New Repository
baseurl=http://newrepo.example.com/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://newrepo.example.com/RPM-GPG-KEY-newrepo

Enabling/Disabling Repositories

To enable or disable a repository, edit the repository file and set the enabled directive to 1 (enable) or 0 (disable).

Example Commands

  • List all available repositories:

    yum repolist all
  • Enable a specific repository:

    sudo yum-config-manager --enable example-repo
  • Disable a specific repository:

    sudo yum-config-manager --disable example-repo

Conclusion

The /etc/yum.repos.d/ directory is a critical component for managing software repositories in YUM. By understanding how to create and configure repository files, you can efficiently manage where YUM looks for packages and how it handles package installations and updates. This flexibility allows for better control over your system's software sources and package management.

Last updated