Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»General Articles»How To Add/Remove Repository In Fedora using DNF

    How To Add/Remove Repository In Fedora using DNF

    By RahulMay 21, 20234 Mins Read

    In the world of Linux, Fedora is a highly popular distribution because of its focus on innovation, community involvement, and incorporation of new technologies. One such technology is DNF, the next-generation package management system for Fedora. DNF (Dandified Yum) is a software package manager that installs, updates, and removes packages on RPM-based Linux distributions. It became the default package manager for Fedora 22 and later versions, replacing the YUM tool.

    Advertisement

    Repositories, also known as “repos”, are storage locations from which software packages can be retrieved and installed. This article aims to provide a comprehensive guide on adding and removing repositories in Fedora using DNF.

    Understanding Repositories

    Before proceeding with the steps for adding or removing repositories, let’s first understand what repositories are. Repositories are server directories that contain packages, metadata files, and other data necessary for package management operations. Repositories may be standard, testing, or third-party, depending on their source and stability.

    When you install a package using DNF, it looks into these repositories, finds the relevant package, downloads it, and installs it on your system. The list of repositories your system knows about can be found in the /etc/yum.repos.d/ directory.

    Adding Repositories Manually

    To add a repository, you need to create a new .repo file in the /etc/yum.repos.d/ directory. Let’s say we want to add a repository called ‘MyRepo’. Here are the steps:

    1. Open Terminal: You can do this by pressing Ctrl + Alt + T on your keyboard.
    2. Create a New File: Type sudo nano /etc/yum.repos.d/MyRepo.repo in the terminal and press Enter. Replace ‘MyRepo’ with the name of your repository.
    3. Add the Repository Details: In the editor, add your repository details. Below is an example of what this might look like:

      1
      2
      3
      4
      5
      6
      [MyRepo]
      name=My Repository
      baseurl=http://www.example.com/myrepo/
      enabled=1
      gpgcheck=1
      gpgkey=http://www.example.com/myrepo/RPM-GPG-KEY-my-repo

      In the example above:

      • `MyRepo`: Is the repository ID.
      • `name`: The human-readable name of the repository.
      • `baseurl`: The URL for the repository.
      • `enabled=1`: This enables the repository. To disable, change this to 0.
      • `gpgcheck=1`: This enables GPG signature checking. To disable, change this to 0.
      • `gpgkey`: The URL for the GPG key that should be used to sign the packages.
    4. Save and Close: Press Ctrl + X, then Y to save and exit.
    5. Update DNF: To make sure that DNF knows about your new repository, update it using sudo dnf makecache.

    Adding Repositories with DNF config-manager

    DNF config-manager is a plugin for DNF that manages your repositories as well as DNF configuration. While the basic DNF does a wonderful job, the config-manager can simplify your life even more, making adding and removing repositories much easier.

    1. Before proceeding, ensure the dnf-plugins-core package is installed in your Fedora system. If not, you can install it using:
      sudo dnf install dnf-plugins-core 
      
    2. Adding Repositories with DNF config-manager: Let’s say you want to add a repository from the URL http://www.example.com/myrepo/. With dnf config-manager, it’s as simple as this:
      sudo dnf config-manager --add-repo http://www.example.com/myrepo/ 
      

      The above command will create a .repo file under /etc/yum.repos.d/ for you.

    3. Enabling and Disabling Repositories: The dnf config-manager can also be used to enable and disable repositories. To enable a repository, use the –set-enabled option:
      sudo dnf config-manager --set-enabled MyRepo 
      

      Similarly, to disable a repository, use the –set-disabled option:

      sudo dnf config-manager --set-disabled MyRepo 
      

      Remember to replace ‘MyRepo’ with the name of your repository.

    Removing Repositories

    Removing a repository is simpler. All you need to do is delete the .repo file you wish to remove. To remove the ‘MyRepo’ repository, you would:

    1. Open a terminal by pressing Ctrl + Alt + T.
    2. Then delete the repository file using rm command.
      sudo rm /etc/yum.repos.d/MyRepo.repo 
      

    After performing these steps, DNF will no longer know about the repository, and it will not attempt to retrieve or install packages from it.

    Conclusion

    Repositories are integral to package management on Fedora, and understanding how to add and remove them is a crucial part of managing your system. The DNF tool makes this easy, and it is a powerful tool for package management.

    Remember, when dealing with third-party repositories, only add repositories from sources that you trust, as packages installed from a repository have the same level of access to your system as any other software. Always ensure you have verified the integrity and authenticity of any third-party repository before adding it to your system.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How To Block Specific Keywords Using Squid Proxy Server

    How To Block Specific Domains Using Squid Proxy Server

    A Comprehensive Look at the Simple Mail Transfer Protocol (SMTP)

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Setting Up Angular on Ubuntu: Step-by-Step Guide
    • Converting UTC Date and Time to Local Time in Linux
    • Git Restore: Functionality and Practical Examples
    • Git Switch: Functionality and Practical Examples
    • Git Switch vs. Checkout: A Detailed Comparison with Examples
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.