作为一个例子,我正在寻找一个mod_files.sh文件,该文件可能会随php-devel包而来。我猜yum会用php-devel x86_64 5.1.6-23.2安装mod_files.sh文件。El5_3包,但文件似乎没有安装在我的文件系统。
如何找出哪个包安装了特定的文件?我正在寻找我不一定已经在本地下载的包,其中可能包括我正在寻找的文件。
我用的是CentOS 5。
作为一个例子,我正在寻找一个mod_files.sh文件,该文件可能会随php-devel包而来。我猜yum会用php-devel x86_64 5.1.6-23.2安装mod_files.sh文件。El5_3包,但文件似乎没有安装在我的文件系统。
如何找出哪个包安装了特定的文件?我正在寻找我不一定已经在本地下载的包,其中可能包括我正在寻找的文件。
我用的是CentOS 5。
您访问http://www.rpmfind.net并搜索该文件。
您将得到许多不同发行版和版本的结果,但很可能也会弹出Fedora和/或CentOS,并且您将知道要与yum一起安装的软件包名称
这是一个老问题,但目前的答案是不正确的:)
使用yum what所提供的文件的绝对路径(可以是通配符)。例如:
yum whatprovides '*bin/grep'
返回
grep-2.5.1-55.el5.x86_64 : The GNU versions of grep pattern matching utilities.
Repo : base
Matched from:
Filename : /bin/grep
您可能更喜欢yum-utils包中提供的repoquery工具的输出和速度。
sudo yum install yum-utils
repoquery --whatprovides '*bin/grep'
grep-0:2.5.1-55.el5.x86_64
grep-0:2.5.1-55.el5.x86_64
Repoquery可以执行其他查询,如列出包内容、依赖项、反向依赖项等。
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
最普遍的答案是不完整的:
由于这种搜索通常只会对已安装包中的文件执行,yum whatproviders通过禁用所有外部repo(隐式的“已安装”repo不能禁用)来实现极快的速度。
yum --disablerepo=* whatprovides <file>
你可以在这里做同样的事情,但是用你的包。在我的例子中,它是lsb_release
执行命令:yum whatproviders lb_release
回应:
redhat-lsb-core-4.1-24.el7.i686 : LSB Core module support
Repo : rhel-7-server-rpms
Matched from:
Filename : /usr/bin/lsb_release
redhat-lsb-core-4.1-24.el7.x86_64 : LSB Core module support
Repo : rhel-7-server-rpms
Matched from:
Filename : /usr/bin/lsb_release
redhat-lsb-core-4.1-27.el7.i686 : LSB Core module support
Repo : rhel-7-server-rpms
Matched from:
Filename : /usr/bin/lsb_release
redhat-lsb-core-4.1-27.el7.x86_64 : LSB Core module support
Repo : rhel-7-server-rpms
Matched from:
Filename : /usr/bin/lsb_release`
执行命令install: yum install redhat-lsb-core
包装名称应该没有数字和系统类型,以便包装商可以选择最适合他的。
只使用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/