How to Enable and Disable Repositories in CentOS

CentOS repositories are collections of software packages that are stored in repositories and can be installed on your system via yum or dnf package managers.

What Are CentOS Repositories?

Use the command yum repolist or dnf repolist to list all currently enabled repositories in CentOS.

Check Available Repositories

To enable a specific repository, run: sudo yum-config-manager --enable <repository-name> or sudo dnf config-manager --enable <repository-name>.

Enable a Repository

To disable a repository, use the command: sudo yum-config-manager --disable <repository-name> or sudo dnf config-manager --disable <repository-name>.

Disable a Repository

You can enable or disable a repository for a single session using the --enablerepo or --disablerepo flag in your yum or dnf commands.

Enable/Disable Repositories Temporarily

Repository configurations are stored in /etc/yum.repos.d/. You can manually edit these .repo files to enable or disable repositories by changing the enabled=1 or enabled=0 values.

Managing Repository Files

Once you enable or disable a repository, verify the changes by running yum repolist or dnf repolist again to ensure your modifications have taken effect.

Verify Enabled Repositories