作为一个例子,我正在寻找一个mod_files.sh文件,该文件可能会随php-devel包而来。我猜yum会用php-devel x86_64 5.1.6-23.2安装mod_files.sh文件。El5_3包,但文件似乎没有安装在我的文件系统。

如何找出哪个包安装了特定的文件?我正在寻找我不一定已经在本地下载的包,其中可能包括我正在寻找的文件。

我用的是CentOS 5。


当前回答

只使用rpm实用程序,这应该适用于任何有rpm的操作系统:

rpm -q --whatprovides [file name]

引用https://www.thegeekdiary.com/how-to-find-which-rpm-package-provides-a-specific-file-or-library-in-rhel-centos/

其他回答

只使用rpm实用程序,这应该适用于任何有rpm的操作系统:

rpm -q --whatprovides [file name]

引用https://www.thegeekdiary.com/how-to-find-which-rpm-package-provides-a-specific-file-or-library-in-rhel-centos/

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:

for file in `find ~/cent_os_dvd/ -iname '*.rpm'`;  do rpm -qlp $file |grep '.*bin/semanage';  if [ $? -eq 0 ]; then echo "is in";echo $file  ; fi;  done

您访问http://www.rpmfind.net并搜索该文件。

您将得到许多不同发行版和版本的结果,但很可能也会弹出Fedora和/或CentOS,并且您将知道要与yum一起安装的软件包名称

要知道包拥有(或提供)一个已经安装的文件:

rpm -qf myfilename

最普遍的答案是不完整的:

由于这种搜索通常只会对已安装包中的文件执行,yum whatproviders通过禁用所有外部repo(隐式的“已安装”repo不能禁用)来实现极快的速度。

yum --disablerepo=* whatprovides <file>