Bootstrap FreeKB - DNF - Enable or disable a DNF repository
DNF - Enable or disable a DNF repository

Updated:   |  DNF articles

Let's say the /etc/yum.repos.d directory should contains the following files.

~]$ ll /etc/yum.repos.d/
-rw-r--r--. 1 root root 1664 Apr  7  2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Apr  7  2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Apr  7  2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Apr  7  2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Apr  7  2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Apr  7  2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 7577 Apr  7  2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  616 Apr  7  2020 CentOS-x86_64-kernel.repo
-rw-r--r--  1 root root 1050 Oct 31  2020 epel.repo
-rw-r--r--  1 root root 1149 Oct 31  2020 epel-testing.repo

 

In this example, in the /etc/yum.repos.d/epel.repo file, only the "epel" block is enabled (enabled=1). The epel-debuginfo and epel-source blocks are disabled (enabled=0). A block can be permanently enabled (1) or disabled (0) by editing the .repo file.

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch&infra=$infra&content=$contentdir
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch&infra=$infra&content=$contentdir
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch&infra=$infra&content=$contentdir
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

 

A repository can be enabled using the following command. Once enabled, the repository should no longer be returned in the dnf repolist command, and "enabled" in the .repo file should be 1 (enabled).

dnf config-manager --set-enabled epel

 

A repository can be disabled using the following command. Once disabled, the repository should no longer be returned in the dnf repolist command, and "enabled" in the .repo file should be 0 (disabled).

dnf config-manager --set-disabled epel

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 3c4915 in the box below so that we can be sure you are a human.