Posted on
Administration

Leveraging repoquery for DNF/YUM

Author
  • User
    Linux Bash
    Posts by this author
    Posts by this author

Leveraging Repoquery in Linux: A Guide for DNF/YUM with Insights on APT and Zypper

In the sprawling universe of Linux, managing packages efficiently is essential for administrators and developers alike. Repoquery, a part of the yum-utils toolset for YUM and now DNF-based systems, stands out as an invaluable tool for querying detailed information about packages in repositories. Although primarily designed for RPM Package Manager (RPM)-based distributions, the underlying concept of querying package repositories is universally applicable. In this post, we'll explore how to use repoquery effectively with DNF/YUM and touch on similar functionality in APT for Debian-based systems and Zypper for SUSE-based systems.

What is Repoquery?

Repoquery is a command-line tool used to query information from YUM or DNF repositories about available packages, dependencies, and much more. It's particularly useful for users who need to handle packages without necessarily installing them, offering insights into package versions, architectures, and dependency trees.

Using Repoquery with DNF and YUM

DNF (Dandified YUM) has largely replaced YUM in recent Fedora releases, but the functionality of repoquery remains largely the same.

Basic Commands

  1. List All Available Packages:

    dnf repoquery
    

    This command lists all packages available in all enabled repositories.

  2. Search for Specific Packages:

    dnf repoquery 'package-name'
    

    Replace 'package-name' with the actual package name to get detailed information.

  3. List Dependencies of a Package:

    dnf repoquery --requires --resolve 'package-name'
    

    This shows packages that the specified package depends on.

  4. Find What Package Provides a Specific File:

    dnf repoquery --whatprovides 'file-or-feature'
    

    Useful for identifying the package providing a specific file or capability.

Additional Useful Commands

  • List Available Versions of a Package:

    dnf repoquery --show-duplicates 'package-name'
    
  • Identify Packages Using Most Space:

    dnf repoquery --qf "%{name} %{size}" | sort -n -k 2
    

Repoquery on APT-Powered Systems

Though APT does not have a direct equivalent of repoquery, several commands offer similar functionality:

  1. Search for Packages:

    apt-cache search 'package-name'
    
  2. Get Detailed Package Information:

    apt-cache show 'package-name'
    
  3. Check Dependencies:

    apt-cache depends 'package-name'
    
  4. See Reverse Dependencies:

    apt-cache rdepends 'package-name'
    

Repoquery for Zypper-Based Distribution

Zypper, used in openSUSE and other SUSE-based systems, is another powerful package manager, akin to DNF and APT. To achieve functionality similar to repoquery, use:

  1. Search for Package Information:

    zypper info 'package-name'
    
  2. List Package Dependencies:

    zypper info --requires 'package-name'
    
  3. Search for a Package Providing a Feature:

    zypper se --provides 'feature-name'
    

Conclusion

Understanding and utilizing repoquery in DNF/YUM can streamline the process of managing packages, providing invaluable insights into package details and dependencies without installing them. APT and Zypper offer varied but similarly powerful tools to maintain system integrity and efficiency. Familiarizing yourself with these tools on different Linux distributions can greatly enhance your capabilities in managing packages and dependencies effectively.