Enable or Disable yum/dnf Repositories

This article provides a guide demonstrating how to enable or disable yum/dnf repositories on RHEL-based Linux VPS or dedicated servers.

Pre-requisites

This guide assumes the following environment pre-requisites have been met:

  • RHEL-based Linux Server (CentOS/AlmaLinux/Rocky Linux/Oracle Linux/Etc)
  • Root (or Sudo User) access

Launch 100% SSD VPS from $2.49/mo!

How to Enable or Disable yum/dnf Repositories

To enable or disable yum/dnf repositories, follow the guide:

Info! Replace any instance of '<repo_name>' with the actual name of the repository.

Temporarily Enable or Disable yum/dnf Repositories

  • Temporarily enable a disabled repo (for one command):
    1. SSH the server as root-equivalent user.
    2. Run the following command:
      • sudo yum --enablerepo=<repo_name> install package
      • sudo dnf --enablerepo=<repo_name> install package
  • Temporarily disable a disabled repo (for one command)
    1. SSH the server as root.
    2. Run the following command:
      • sudo yum --disablerepo=<repo_name> update
      • sudo dnf --disablerepo=<repo_name> update

Permanently Enable or Disable yum/dnf Repositories

  • Permanently enable a disabled repository:
    1. SSH the server as root.
    2. Run the following command:
      • sudo dnf config-manager --set-enabled <repo_name>
      • sudo yum config-manager --set-enabled <repo_name>
  • Permanently disable a repository:
    1. SSH the server as root.
    2. Run the following command:
      • sudo dnf config-manager --set-disabled <repo_name>
      • sudo yum config-manager --set-disabled <repo_name>

Launch 100% SSD VPS from $2.49/mo!

Conclusion

You now know how to enable or disable yum/dnf repositories.

  • yum, dnf, centos, rocky linux, almalinux 8, oracle linux, rhel
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How to Create Sudo User on CentOS

This article provides step-by-step setup guide for adding Sudo user to CentOS system. The sudo...

How to Use Sudo

This article provides a guide to using a Sudo user on CentOS server. From the command line,...

Set Server Time Zones with Timedatectl

This article provides a guide to setting the server time and server time zone settings using...

htaccess RewriteRule Examples

Here are some useful mod_rewrite RewriteRule redirect examples that you can use in your .htaccess...

Using htaccess File to Block IPs

If your webserver is Apache, you may block access to your website from specific IP addresses...