如何找到哪个 rpm 软件包提供了我正在寻找的文件?

发布于 2024-07-29 00:59:31 字数 304 浏览 7 评论 0原文

例如,我正在寻找一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

猫弦 2024-08-05 00:59:31

这是一个老问题,但当前的答案不正确:)

使用yum whatprovides,以及所需文件的绝对路径(可能是通配符)。 例如:

yum whatprovides '*bin/grep'

Returns

grep-2.5.1-55.el5.x86_64 : The GNU versions of grep pattern matching utilities.
Repo        : base
Matched from:
Filename    : /bin/grep

您可能更喜欢 repoquery 工具的输出和速度,该工具可在 yum-utils 包中找到。

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 可以执行其他查询,例如列出包内容、依赖项、反向依赖项等。

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:

yum whatprovides '*bin/grep'

Returns

grep-2.5.1-55.el5.x86_64 : The GNU versions of grep pattern matching utilities.
Repo        : base
Matched from:
Filename    : /bin/grep

You may prefer the output and speed of the repoquery tool, available in the yum-utils package.

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 can do other queries such as listing package contents, dependencies, reverse-dependencies, etc.

权谋诡计 2024-08-05 00:59:31

要了解拥有(或提供)已安装文件的包:

rpm -qf myfilename

To know the package owning (or providing) an already installed file:

rpm -qf myfilename
罗罗贝儿 2024-08-05 00:59:31

最流行的答案是不完整的:

由于此搜索通常仅针对已安装软件包中的文件执行,因此通过禁用所有外部存储库(隐式“已安装”存储库不能已禁用)。

yum --disablerepo=* whatprovides <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).

yum --disablerepo=* whatprovides <file>
坏尐絯℡ 2024-08-05 00:59:31

您转到 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

南七夏 2024-08-05 00:59:31

当您连接到互联网(存储库)时,找到软件包很容易,但是当您只能访问 Redhat 或 Centos DVD 中的 RPM 软件包时(当我必须恢复服务器并且需要应用程序时,这种情况经常发生在我身上)我建议使用下面的命令完全独立于互联网和存储库。 (假设您的 DVD 中有很多未安装的软件包)。
假设您已经在 ~/cent_os_dvd 中安装了 Package 文件夹,并且您正在寻找提供“semanage”的包,那么您可以运行:

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

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
回忆凄美了谁 2024-08-05 00:59:31

仅使用 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/

Using only the rpm utility, this should work in any OS that has rpm:

rpm -q --whatprovides [file name]

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

翻身的咸鱼 2024-08-05 00:59:31

您可以在这里执行类似的操作,但要使用您的包。 就我而言,它是 lsb_release

运行:yum whatprovides lsb_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`

运行以安装: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:

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`

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.

最单纯的乌龟 2024-08-05 00:59:31

根据我们是否知道文件路径,我们可以选择下面提到的两个选项之一。

  • 如果我们知道文件的路径,则按照 RPM 命令的手册页进行操作

    查询选项 
      rpm 查询命令的一般形式是 
    
      rpm {-q|--query} [选择选项] [查询选项] 
    
      套餐选择选项: 
      包裹名字 
             查询已安装的名为 PACKAGE_NAME 的包。 
    
      -f, --文件 文件 
             查询包所属的FILE。 
      

可以非常简单地识别相应的 RPM 包。
例如:

[root@e2e-64-147 ~]# rpm -qf /usr/bin/lesspipe.sh
less-458-9.el7.x86_64
  • 如果只知道文件名而不知道路径,那么我们可以使用带有provides选项的yum命令来识别相应的RPM包。
    例如:

    [root@e2e-64-147 ~]# yum -q 提供 '*lesspipe.sh*' 
      less-458-9.el7.x86_64 :类似于 more 的文本文件浏览器,但更好 
      回购:基地 
      匹配自: 
      文件名:/usr/bin/lesspipe.sh 
      

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

    QUERY OPTIONS
    The general form of an rpm query command is
    
    rpm {-q|--query} [select-options] [query-options]
    
    PACKAGE SELECTION OPTIONS:
    PACKAGE_NAME
           Query installed package named PACKAGE_NAME.
    
    -f, --file FILE
           Query package owning FILE.
    

it's pretty straightforward to identify the corresponding RPM package.
For example:

[root@e2e-64-147 ~]# rpm -qf /usr/bin/lesspipe.sh
less-458-9.el7.x86_64
  • 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:

    [root@e2e-64-147 ~]# yum -q provides '*lesspipe.sh*'
    less-458-9.el7.x86_64 : A text file browser similar to more, but better
    Repo        : base
    Matched from:
    Filename    : /usr/bin/lesspipe.sh
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文