Chapter 10. Managing custom software repositories

You can configure a repository in the /etc/dnf/dnf.conf file or in a .repo file in the /etc/yum.repos.d/ directory.

The configuration information for DNF and related utilities are stored in the /etc/dnf/dnf.conf file. This file contains the [main] section and can contain one or more [repository] sections, which allow you to set repository-specific options. The values you define in individual [repository] sections of the /etc/dnf/dnf.conf file override values set in the [main] section.

However, it is recommended to define individual repositories in new or existing .repo files in the /etc/yum.repos.d/ directory.

In the following sections, learn how to manage custom software repositories by using DNF:

10.1. Setting DNF repository options

The /etc/dnf/dnf.conf configuration file contains the [repository] sections, where repository is a unique repository ID. The [repository] sections allow you to define individual DNF repositories.

Note

Do not give custom repositories names used by the Red Hat repositories to avoid conflicts.

For a complete list of available [repository] options, see the [repository] OPTIONS section of the dnf.conf(5) man page.

10.2. Adding a DNF repository

To define a new repository, you can either:

  • Add a [repository] section to the /etc/dnf/dnf.conf file.
  • Add a [repository] section to a .repo file in the /etc/yum.repos.d/ directory.

    Installed RPMs or software management tools, for example, Subscription Manager, can provide their own .repo file.

Note

Define your repositories in a .repo file instead of /etc/dnf/dnf.conf because all files with the .repo file extension in this directory are read by dnf.

To add a DNF repository to your system by using the dnf config-manager command, complete the following steps.

Procedure

  • Add a repository to your system:

    # dnf config-manager --add-repo repository_URL

    Replace repository_url with URL pointing to the repository.

Warning

Obtaining and installing software packages from unverified or untrusted sources other than Red Hat certificate-based Content Delivery Network (CDN) is a potential security risk, and can lead to security, stability, compatibility, and maintainability issues.

10.3. Enabling a DNF repository

To enable a DNF repository added to your system by using the dnf config-manager command, complete the following steps.

Procedure

  • Enable a repository:

    # dnf config-manager --enable repositoryID

    Replace repositoryID with the unique repository ID.

Additional resources

Listing repositories

10.4. Disabling a DNF repository

To disable a DNF repository added to your system by using the dnf config-manager command, complete the following steps.

Procedure

  • Disable a repository:

    # dnf config-manager --disable repositoryID

    Replace repositoryID with the unique repository ID.

Additional resources

Listing repositories