How do I find which rpm package supplies a file I'm looking for?

后端 未结 7 1003
攒了一身酷
攒了一身酷 2020-12-04 05:11

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 i

相关标签:
7条回答
  • 2020-12-04 05:53

    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
    
    0 讨论(0)
  • 2020-12-04 05:55

    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.

    0 讨论(0)
  • 2020-12-04 05:58

    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

    0 讨论(0)
  • 2020-12-04 06:01

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

    rpm -qf myfilename
    
    0 讨论(0)
  • 2020-12-04 06:05

    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/

    0 讨论(0)
  • 2020-12-04 06:09

    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.

    0 讨论(0)
提交回复
热议问题