Last updated on July 29, 2020 by Dan Nanni
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.
yum
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.
$ yum whatprovides /usr/bin/mysqladmin
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
.
repoquery
The second method is via repoquery
, a command-line utility for querying Yum repositories.
To install repoquery
on CentOS, Fedora or RHEL:
$ sudo yum install yum-utils
To run repoquery
to search for a package that contains a file, use the following format.
$ repoquery --whatprovides '/usr/bin/mysqldump'
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
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean