How to Enable or Disable yum/dnf repository

June 9, 2025 / Command Line

This guide explains how to enable or disable yum/dnf repository, this can be done temporarily through the command line or permanently by editing the repo configuration file.

Follow the guide:

To temporarily enable or Disable a Repo (CLI Method)

  1. Enable a disabled repo for one command:
    yum --enablerepo=repo-name install package

    # or

    dnf --enablerepo=repo-name install package
  2. Disable a repo for one command:
    yum --disablerepo=repo-name update

    # or

    dnf --disablerepo=repo-name update

To permanently enable or disable a Repo

  1. List all available repositories using the following command:
    yum repolist all

    # or

    dnf repolist all
  2. Edit the repository file:
    Repo files are located in:

    /etc/yum.repos.d/

    To edit a specific repo (e.g., kb.repo):

    sudo vi /etc/yum.repos.d/kb.repo
  3. Change the enabled line:
    To disable:

    enabled=0

    To enable:

    enabled=1
  4. Save and exit.

This way, you can enable or disable yum/dnf repository. If you need further assistance, do contact our support specialists. They are available for you 24X7.

Next step in managing YUM/DNF: Learn How to clear the Yum cache

Spread the love