How to enable or disable repositories on Fedora Linux?

Fedora is one of the most popular Linux distributions out there! The Creator and maintainer of Linux, Linus Torvalds, has even said that Fedora is the Linux distribution with most sane defaults. However, this Linux distribution only ships with Free and Open Source software and thus, does not include few important codecs which are required for playing any kind of media on your device.

To add these codecs and essential software, you must add the free and non-free COPR repositories to your system after installing Fedora on your PC. We have discussed the first steps to take after installing Fedora in another article, however, in this tutorial, we will simply learn to disable and remove unwanted repositories from our distribution as refreshing these repositories take some time whenever you try to install packages or update your system.

How to add repositories on Fedora?

In order to add any repository to your Fedora workstation, you have to type the following commands in the terminal window:

dnf config-manager --add-repo #repository

Obviously, the repository at the end should be replaced with the appropriate repository you are trying to add. We can take the example of adding the SwayFX repository to our Fedora system. SwayFX is a lightweight window manager which can improve your workflow by tiling the new windows whenever you open them.

You can add the repository by typing the following command:

sudo dnf copr enable swayfx/swayfx

Obviously, make sure that you refresh the packages by typing the following command:

\sudo dnf update
Enabling A Repository On Fedora
Enabling A Repository On Fedora

There’s another method through which you can add any repository to your Fedora workstation, and that’s by downloading the REPO file itself from any source. You can move the file to the /etc/yum.d/ directory as well.

How to disable Repositories on Fedora?

If you are not using software from several repositories, then it might be a good option to just disable them on your system, otherwise they will keep refreshing every time you update your PC and take up more of your time.

In order to disable any repositories, you first have to list them in the terminal. You can do that by typing:

dnf repolist
Listing Enable Repositories In Fedora
Listing Enable Repositories In Fedora

As you can see, the previously added SwayFX repository is present as a file in this directory! Now, let’s say that I want to disable the same repository, I can do that by typing:

dnf config-manager --set-disabled <REPO ID>

Replace the <REPO ID> with the actual ID of the repository you want to disable. In my case, it would be copr:copr.fedorainfracloud.org:swayfx:swayfx

Disabling Repositories In Fedora
Disabling Repositories In Fedora

As you can see, the repository is no longer listed once I have disabled it. You can also remove the repository from your PC if you want.

Removing a repository from Fedora

If you want to remove a repository, then you’ll first have to list all the repositories which are present on your system. To do that, use the command listed below:

ls /etc/yum.repos.d/
Listing The Repositories Present On Your System
Listing The Repositories Present On Your System

Now you can remove them by typing the command like this:

sudo rm /etc/yum.repos.d/#REPOSITORYNAME_HERE

Make sure to type the correct name of the repository which you are trying to remove.

Removing Repositories From Your System
Removing Repositories From Your System

That’s about it! You have now learned how to manage repositories on your PC on which Fedora workstation is installed.

Summary

While the developers have made the switch from yum to DNF, the package manager is still quite slow. I have used Endeavour OS in a virtual machine and the difference between using DNF and pacman was quite evident. By removing the additional repositories which you are not using, you can save a lot of time while updating or installing applications on your PC. I’m using Nobara Linux, which is based on Fedora and has a lot of modifications done by the one and only GloriousEgroll, the developer of ProtonGE. But now that I do not use my laptop to play games anymore, I am considering switching to something lightweight, fast and even has a faster package manager. But do let me know what do you think about Fedora and DNF overall.