If you know the name of a package you want, it is straightforward to install the package with a software package manager, such as yum on RedHat-based systems. However, what if all you know is the name of an executable binary or library file that is missing, and you want to install whatever package that provides the file?
In this tutorial, I will explain how to find what package a particular file belongs to on RHEL-based platforms such as CentOS or Fedora.
There are two ways to find out what package contains a specific file on CentOS or Fedora.
The first method is to use yum command itself. With "whatprovides" option, yum allows you to search for which package provides a requested file. With the option, you can specify the full path to a specific file, or wildcards for multiple files.
mysql-5.1.66-2.el6_3.x86_64 : MySQL client programs and shared libraries Repo : base Matched from: Filename : /usr/bin/mysqladmin mysql-5.1.69-1.el6_4.x86_64 : MySQL client programs and shared libraries Repo : updates Matched from: Filename : /usr/bin/mysqladmin mysql-5.1.67-1.el6_3.x86_64 : MySQL client programs and shared libraries Repo : updates Matched from: Filename : /usr/bin/mysqladmin mysql-5.1.69-1.el6_4.x86_64 : MySQL client programs and shared libraries Repo : installed Matched from: Filename : /usr/bin/mysqladmin
As you can see above, the mysqladmin command located in /usr/bin is contained in a software package called mysql.
The second method is via repoquery, a command-line utility for querying YUM repositories.
To install repoquery on CentOS, Fedora or RHEL:
To run repoquery to search for a package that contains a file, use the following format.
mysql-0:5.1.69-1.el6_4.x86_64 mysql-0:5.1.66-2.el6_3.x86_64 mysql-0:5.1.67-1.el6_3.x86_64
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!
Latest posts by Dan Nanni (see all)
- How to set up Apt caching server on Ubuntu or Debian - February 7, 2016
- How to monitor OpenFlow messages with packet sniffer - February 2, 2016
- How to search multiple pdf documents for words on Linux - January 13, 2016