Find What Package Provides a Specific File on RHEL, CentOS, Fedora with repoquery

Shahriar Shovon

Supported OS

  • All

Categories

Share this post with your friends

In your system administration life time, suppose you're looking forward to edit a configuration file and it turns out that the file is not available. You forgot what package to install to have that file or what package contains that file. What would you do then? To get the answer, read this post. To find out which package in the repository contains a specific file, you can use the repoquery command. The syntax to do that is, repoquery -qf file_path Here file_path is the file that you're looking for.

Example: Find the package that is associated with a specific file /etc/my.cnf

To check what package provides the file /etc/my.cnf, run the following command. repoquery -qf /etc/my.cnf mariadb-libs-1:5.5.44-2.el7.centos.x86_64 mariadb-libs-1:5.5.44-2.el7.centos.i686 From the output, we can see that the packages that provides the specific file /etc/my.cnf is mariadb-libs. Tested on: CentOS 7