add/remove software repository

How to Add/Remove Software Repository in Fedora

Each Fedora distribution comes with a set of software repositories that provide a collection of free and open source software. Generally, when you use package managers like Yum (Yellowdog Updater, Modified) they basically connect to these repositories to download & install the software you require. But sometimes the software you need may not be present in any of the official repositories. In such cases, you need to add a new repository to your system, in order to allow your package manager to install it for you. In this article, we will learn how to add/remove software repository in Fedora.



How to Add/Remove Software Repository in Fedora

Here are the key commands to manage your software repositories.

View Enabled Repositories

Run the following command to view all the software repositories in your Fedora system, with details including ID, name and status.

$ sudo dnf repolist

The above command will list all repositories on your system. If you want to list all packages from a specific repository, use repository-packages command as shown below.

$ sudo dnf repository-packages fedora list

The above command will display both available as well as installed packages present in your repository.

If you want to view only available packages in a specific repository you can mention that option in command, as shown below.

$ sudo dnf repository-packages fedora list available
OR
$ sudo dnf repository-packages fedora list installed

How to Add, Enable and Disable DNF Repository

Before you add a new repository to your system, you need to add [repository] section to /etc/dnf/dnf.conf file or to a .repo file in /etc/yum.repos.d/ directory.

For example, to add repo for Grafana in .repo file,

$ sudo vim /etc/yum.repos.d/grafana.repo

Add [repository] section in the file and save it. Here is an example configuration.

add/remove software repository

In the above example, we have set enabled=0 so that it is not enabled by default. You can set it to 1 if you want to directly enable it.

Otherwise, you can also use the following command to enable a new repository via terminal.

$ sudo dnf config-manager --add-repo /etc/yum.repos.d/grafana.repo

If you want to enable or disable DNF repository, while installing a package from it, use –enablerepo or –disablerepo options as shown below.

$ sudo dnf --enablerepo=grafana install grafana  
OR
$ sudo dnf --disablerepo=fedora-extras install grafana  

You can enable or disable multiple repositories with a single command as shown below.

$ sudo dnf --enablerepo=grafana, repo2, repo3 install grafana package2 package3 
OR
$ sudo dnf --disablerepo=fedora, fedora-extras, remi install grafana 

In the 1st example above, we enable repos grafana, repo2, repo3 and install packages grafana package2 and package3. In the 2nd example above, we disable repositories fedora, fedora-extras and remi.

In fact, you can enable certain repos and disable some other repos using a single command as shown.

$ sudo dnf --enablerepo=grafana --disablerepo=fedora, fedora_extra, remi, elrepo install grafana

In the above command we combine both enablerepo and disablerepo options. It will read the repo names supplied for enablerepo option and enable them, and read the repo names mentioned for disablerepo option and disable them.

Please note, in most systems, the above command will only enable the repository till you reboot the system and not do it permanently.

If you want to permanently enable repository, you need to use –set-enabled option.

$ sudo grep enable /etc/yum.repos.d/grafana.repo
$ sudo dnf config-manager --set-enabled grafana
$ sudo grep enable /etc/yum.repos.d/grafana.repo

To permanently disable repository, use –set-disabled option.

$ sudo dnf config-manager --set-disabled grafana

In this article, we have learnt how to add/enable/disable software repositories in fedora. If you need to install a software that is maintained in a separate, non-official repository, you can add them to your system using above commands. Similarly, if you find that a repository is outdated and no longer being maintained, you can disable it using the above commands.

Also read:

How to Password Protect Vim File
How to Check Linux Server Location
How to Encrypt Drives Using LUKS in Encryption
How to Limit Memory & Time of Processes in Linux
How to Use Yum History to Find Installed or Removed Packages

Leave a Reply

Your email address will not be published. Required fields are marked *