如何找到哪个 rpm 软件包提供了我正在寻找的文件?
例如,我正在寻找一个 mod_files.sh
文件,该文件可能随 php-devel
包一起提供。 我猜测 yum
会使用 php-devel x86_64 5.1.6-23.2.el5_3
包安装 mod_files.sh
文件,但是该文件似乎没有安装在我的文件系统上。
如何找出哪个软件包安装了特定文件? 我正在寻找我不一定已经在本地下载的软件包,其中可能包含我正在查找的文件。
我使用的是 CentOS 5。
As an example, I am looking for a mod_files.sh
file which presumably would come with the php-devel
package. I guessed that yum
would install the mod_files.sh
file with the php-devel x86_64 5.1.6-23.2.el5_3
package, but the file appears to not to be installed on my filesystem.
How do I find out which package installs a specific file? I'm looking for where I have not necessarily already locally downloaded the package which may include the file that I'm looking for.
I'm using CentOS 5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
这是一个老问题,但当前的答案不正确:)
使用yum whatprovides,以及所需文件的绝对路径(可能是通配符)。 例如:
Returns
您可能更喜欢
repoquery
工具的输出和速度,该工具可在yum-utils
包中找到。repoquery
可以执行其他查询,例如列出包内容、依赖项、反向依赖项等。This is an old question, but the current answers are incorrect :)
Use yum whatprovides, with the absolute path to the file you want (which may be wildcarded). For example:
Returns
You may prefer the output and speed of the
repoquery
tool, available in theyum-utils
package.repoquery
can do other queries such as listing package contents, dependencies, reverse-dependencies, etc.要了解拥有(或提供)已安装文件的包:
To know the package owning (or providing) an already installed file:
最流行的答案是不完整的:
由于此搜索通常仅针对已安装软件包中的文件执行,因此通过禁用所有外部存储库(隐式“已安装”存储库不能已禁用)。
The most popular answer is incomplete:
Since this search will generally be performed only for files from installed packages, yum whatprovides is made blisteringly fast by disabling all external repos (the implicit "installed" repo can't be disabled).
您转到 http://www.rpmfind.net 并搜索该文件。
您将获得许多不同发行版和版本的结果,但很可能 Fedora 和/或 CentOS 也会弹出,并且您将知道要使用 yum 安装的软件包名称
You go to http://www.rpmfind.net and search for the file.
You'll get results for a lot of different distros and versions, but quite likely Fedora and/or CentOS will pop up too and you'll know the package name to install with yum
当您连接到互联网(存储库)时,找到软件包很容易,但是当您只能访问 Redhat 或 Centos DVD 中的 RPM 软件包时(当我必须恢复服务器并且需要应用程序时,这种情况经常发生在我身上)我建议使用下面的命令完全独立于互联网和存储库。 (假设您的 DVD 中有很多未安装的软件包)。
假设您已经在 ~/cent_os_dvd 中安装了 Package 文件夹,并且您正在寻找提供“semanage”的包,那么您可以运行:
Well finding the package when you are connected to internet (repository) is easy however when you only have access to RPM packages inside Redhat or Centos DVD (this happens frequently to me when I have to recover a server and I need an application) I recommend using the commands below which is completely independent of internet and repositories. (supposably you have lots of uninstalled packages in a DVD).
Let's say you have mounted Package folder in ~/cent_os_dvd and you are looking for a package that provides "semanage" then you can run:
仅使用 rpm 实用程序,这应该可以在任何具有 rpm 的操作系统中运行:
参考。 https://www.thegeekdiary.com/how-to-find-which-rpm-package-provides-a-specific-file-or-library-in-rhel-centos/
Using only the rpm utility, this should work in any OS that has rpm:
Ref. https://www.thegeekdiary.com/how-to-find-which-rpm-package-provides-a-specific-file-or-library-in-rhel-centos/
您可以在这里执行类似的操作,但要使用您的包。 就我而言,它是
lsb_release
运行:
yum whatprovides lsb_release
响应:
运行以安装:
yum install redhat-lsb-core
The包名称应该不包含数字和系统类型,以便 yum 打包者可以选择最适合他的名称。
You can do this alike here but with your package. In my case, it was
lsb_release
Run:
yum whatprovides lsb_release
Response:
Run to install:
yum install redhat-lsb-core
The package name SHOULD be without number and system type so yum packager can choose what is best for him.
根据我们是否知道文件路径,我们可以选择下面提到的两个选项之一。
如果我们知道文件的路径,则按照 RPM 命令的手册页进行操作
可以非常简单地识别相应的 RPM 包。
例如:
如果只知道文件名而不知道路径,那么我们可以使用带有provides选项的yum命令来识别相应的RPM包。
例如:
Depending upon whether we know the file path or not we can choose one of the 2 options mentioned below.
If we know the path of the file then as per the man page for the RPM command
it's pretty straightforward to identify the corresponding RPM package.
For example:
If only the file name is known and the path is not, then we can use the yum command with provides option to identify the corresponding RPM package.
For example: