Product SiteDocumentation Site

6.5. Adding, Enabling, and Disabling a DNF Repository

Section 6.3.2, “Setting [repository] Options” describes various options you can use to define a DNF repository. This section explains how to add, enable, and disable a repository by using the dnf config-manager command.

Adding a DNF Repository

To define a new repository, you can either add a [repository] section to the /etc/dnf/dnf.conf file, or to a .repo file in the /etc/yum.repos.d/ directory. All files with the .repo file extension in this directory are read by DNF, and it is recommended to define your repositories here instead of in /etc/dnf/dnf.conf.
DNF repositories commonly provide their own .repo file. To add such a repository to your system and enable it, run the following command as root:
dnf config-manager --add-repo repository_url
…where repository_url is a link to the .repo file.
Example 6.8. Adding example.repo
To add a repository located at http://www.example.com/example.repo, type the following at a shell prompt:
~]# dnf config-manager --add-repo http://www.example.com/example.repo
adding repo from: http://www.example.com/example.repo

Enabling a DNF Repository

To enable a particular repository or repositories, type the following at a shell prompt as root:
dnf config-manager --set-enabled repository
…where repository is the unique repository ID. To display the current configuration, add the --dump option.

Disabling a DNF Repository

To disable a DNF repository, run the following command as root:
dnf config-manager --set-disabled repository
…where repository is the unique repository ID. To display the current configuration, add the --dump option.