Adding or removing software repositories in Fedora

Anthony McGlone Version F37 Last review: 2023-01-05
This section describes how to add, enable, or disable a software repository with the DNF application.

Adding repositories

This section describes how to add software repositories with the dnf config-manager command.

To add a new repository, use one of the following methods.

  • Define a new repository by creating a new file with the .repo suffix in a temporary location, such as the /tmp directory.

  • Add the repository with addrepo, where repository is the file path:

    $ sudo dnf config-manager addrepo --from-repofile=_repository_

    For example:

    $ sudo dnf config-manager addrepo --from-repofile=/tmp/fedora_extras.repo

Enabling repositories

This section shows how to enable a particular software repository by using the dnf config-manager command.

  • To enable a particular repository, run the following command:

    $ sudo dnf config-manager setopt _repository_.enabled=1

    Where repository is the unique repository ID, for example:

    $ sudo dnf config-manager setopt fedora-extras.enabled=1

Disabling repositories

This section shows how to disable a particular software repository by using the dnf config-manager command.

  • To disable a particular repository, run the following command:

    $ sudo dnf config-manager setopt _repository_.enabled=0

    Where repository is the unique repository ID, for example:

    $ sudo dnf config-manager setopt fedora-extras.enabled=0

Removing repositories

This section shows how to remove a repository (or .repo file).

If you know the ID of a repository, but you are not sure what .repo it belongs to, you can run the following command grep -E "^\[.*]" /etc/yum.repos.d/*. This will print a list of the repository IDs that are associated with each repository.

  • To remove a repository, run the following command:

    $ sudo rm /etc/yum.repos.d/_file_name_.repo

    Where file_name is the name of the .repo file.