Skip to main content

Command Palette

Search for a command to run...

2.6 Managing Software with DNF (dnf): A Comprehensive Guide

Updated
2 min read
2.6 Managing Software with DNF (dnf): A Comprehensive Guide
V

I'm Vijay Kumar Singh, a Linux, DevOps, Cloud enthusiast learner and contributor in shell scripting, Python, networking, Kubernetes, Terraform, Ansible, Jenkins, and cloud (Azure, GCP, AWS) and basics of IT world. 💻✨ Constantly exploring innovative IT technologies, sharing insights, and learning from the incredible Hashnode community. 🌟 On a mission to build robust solutions and make a positive impact in the tech world. 🚀 Let's connect and grow together!

#PowerToCloud

Managing software on a Linux system is a crucial task for system administrators and users alike. DNF (Dandified YUM) is a package manager used in Fedora and other RPM-based Linux distributions. In this guide, we'll explore various commands and operations to efficiently handle software using dnf.

Checking and Upgrading Software

  • Check for upgrades:

      dnf check-upgrade
    
  • Upgrade installed packages:

      sudo dnf upgrade
    

Repository Management

  • Check repository list:

      sudo dnf repolist
    

    or

      sudo dnf repolist -v
    
  • List all repositories (enabled and disabled):

      sudo dnf repolist --all
    
  • Enable/Disable a repository:

      sudo dnf config-manager --enable repo_name
      sudo dnf config-manager --disable repo_name
    
  • Add a new repository:

      sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    
  • Remove a repository:

      sudo rm /etc/yum.repos.d/docker-ce.repo
    

Package Management

  • Search for packages:

      sudo dnf search packageName
    

    For more accuracy:

      sudo dnf search 'packageName'
    
  • Get information about a package:

      sudo dnf info packageName
    
  • Install a package:

      sudo dnf install packageName
    
  • Reinstall a package:

      sudo dnf reinstall packageName
    
  • Uninstall or remove a package:

      sudo dnf remove packageName
    
  • Group Operations:

    • Install a group of packages:

        sudo dnf group install 'packageName'
      
    • List available groups:

        sudo dnf group list
        sudo dnf group list --hidden
      
    • Remove a group of packages:

        sudo dnf group remove 'packageName'
      

Local Package Operations

  • Install a local RPM file:

      sudo dnf install ./packageName.rpm
    
  • Remove a locally installed package:

      sudo dnf remove packageName.rpm
    

Dependency Management

  • Remove unnecessary dependencies:

      sudo dnf autoremove
    

File Management

  • Identify file origin (for troubleshooting):

      dnf provides /etc/anacrontab
    

    After identifying an issue with a file (e.g., bad edits), reinstall the package:

      sudo rm /etc/anacrontab
      dnf reinstall cronie-anacron
    
  • View all files in a package (installed or not):

      dnf repoquery -l packageName
    

This comprehensive guide should empower users and administrators to efficiently manage software on their Linux systems using the versatile dnf package manager.

More from this blog

P

PowerToCloud

85 posts

Talks about bridging the between Dev & Ops using Cloud-Native solutions, Automation. Refining DevOps skills , Excelling in Multi-cloud environment, community engagement & IT solutions.