Question: How to find the package with a missing file in the system using YUM? This how-to is also applicable when the file is not missing and is already installed, but for some reason, it is required to know the package that provides it.
The YUM package manager tool uses repositories to retrieve information and download packages. The repositories configurations are at /etc/yum.repos.d/*.repo files and in these files it can be multiple repositories enabled and others disabled.
1. The sub command to use is “provides”. For example, looking for /usr/src/kernels/4.1.12-124.18.6.el7uek.x86_64 file:
# yum provides /usr/src/kernels/4.1.12-124.18.6.el7uek.x86_64
This will show the repository and package that need to installed to have it in the system.
2. But the command might not find the package because repository that has it is disabled:
No Matches found
In that case it can be attempted to enable all or just one repository to search. For that has to be using option –enablerepo. FOr example, using all repositories configured in the .repo files, eanbled and disabaled.
# yum provides /usr/src/kernels/4.1.12-124.18.6.el7uek.x86_64 --enablerepo=*
or just a specific repo:
# yum provides /usr/src/kernels/4.1.12-124.18.6.el7uek.x86_64 --enablerepo=ol7_UEKR4_archive
or multiple ones matching a regular expression
# yum provides /usr/src/kernels/4.1.12-124.18.6.el7uek.x86_64 --enablerepo=ol7_*_archive
Sample Output:
kernel-uek-devel-4.1.12-124.18.6.el7uek.x86_64 : Development package for building kernel modules to match the kernel Repo : ol7_UEKR4_archive Matched from: Filename : /usr/src/kernels/4.1.12-124.18.6.el7uek.x86_64
3. If the final goal is to install it and it was only possible using option –enablerepo, use same option to install the package:
# yum install kernel-uek-devel-4.1.12-124.18.6.el7uek.x86_64 --enablerepo=ol7_UEKR4_archive
If looking for a file that the path location is unknown, a file path with wildcard can be used:
# yum provides */fileX