Wednesday, 4 November 2020

How to Enable/Disable a Specific Repository in CentOS 7



There are two options [--enablerepo=<reponame> and –disablerepo=<reponame>] available to enable or disable a specific repository during yum installation or update of the packages on CentOS7.
 
This article describes, How to Enable/Disable a Specific Repository in CentOS 7.
 
Enabling Repo: Run the following command to validate the enabled repositories:

[root@linuxcnf ~]# yum repolist
Loaded plugins: fastestmirror
……………………………..
repo id                                                           repo name                                                                                       status
base/7/x86_64                                                     CentOS-7 - Base                                                                                 10,070
epel/x86_64                                                       Extra Packages for Enterprise Linux 7 - x86_64                                                  13,463
extras/7/x86_64                                                   CentOS-7 - Extras                                                                                  413
updates/7/x86_64                                                  CentOS-7 - Updates                                                                               1,134
repolist: 25,080
[root@linuxcnf ~]#
 
Run the following command to enable a specific repository:
 
[root@linuxcnf ~]# yum repolist --disablerepo=* --enablerepo=epel
Loaded plugins: fastestmirror
…………………….
repo id                                                        repo name                                                                                          status
epel/x86_64                                                    Extra Packages for Enterprise Linux 7 - x86_64                                                     13,465
repolist: 13,465
[root@linuxcnf ~]#
 
In the above output, the EPEL repository is enabled for this yum transaction only.
 
Disabling Repo: Run the following command to validate the enabled repositories:
 
[root@linuxcnf ~]# yum repolist
Loaded plugins: fastestmirror
…………………………..
repo id                                                           repo name                                                                                       status
base/7/x86_64                                                     CentOS-7 - Base                                                                                 10,070
epel/x86_64                                                       Extra Packages for Enterprise Linux 7 - x86_64                                                  13,465
extras/7/x86_64                                                   CentOS-7 - Extras                                                                                  413
updates/7/x86_64                                                  CentOS-7 - Updates                                                                               1,134
repolist: 25,082
[root@linuxcnf ~]#
 
Run the following command to disable a specific repository:
  
[root@linuxcnf ~]# yum repolist --disablerepo=epel
Loaded plugins: fastestmirror
…………………………….
repo id                                                                         repo name                                                                         status
base/7/x86_64                                                                   CentOS-7 - Base                                                                   10,070
extras/7/x86_64                                                                 CentOS-7 - Extras                                                                    413
updates/7/x86_64                                                                CentOS-7 - Updates                                                                 1,134
repolist: 11,617
[root@linuxcnf ~]#
 
Done! In the above output, the EPEL Repository is disabled.

No comments:

Post a comment