• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to find which rpm package provides a specific file or library in RHEL / CentOS

by admin

‘The Ask’ here is to find the rpm package from which provides a specific binary like /bin/lvcreate or a library file. There 2 commands which can help you find the rpm package from the file – rpm and yum. You can also find all the files included in a package with the rpm command.

Find rpm package which provides a particular binary file or library file

1. Method 1 : using rpm command

1. Use below rpm commands to find which rpm package provide a particular file.

# rpm -q --whatprovides [file name]

For example, to find which rpm package provides /etc/hosts file, use the command below:

# rpm -q --whatprovides /etc/hosts
setup-2.8.14-23.el6.noarch

To find the rpm package which provides the library file /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgomp.so, use the command below.

# rpm -qf /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgomp.so
gcc-4.4.7-18.el6.x86_64

Similarly, you can also use the command below command as well.

# rpm -qf [file name]

For example,

# rpm -qf /etc/hosts
setup-2.8.14-23.el6.noarch

Method 2 : Using yum command

Below yum command provides the package which owns/provides the file name. To use yum the system should be registered to RHN or an appropriate repository.

# yum whatprovides [file_name]

For example :
One can use following command to identify the package which provides a particular library file:

# yum whatprovides libstdc++
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
libstdc++-4.8.5-4.el7.x86_64 : GNU Standard C++ Library
Repo        : @repo

or to search for a binary:

# yum whatprovides *bin/ls
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
coreutils-8.22-15.el7.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : @repo
Matched from:
Filename    : /bin/ls
Filename    : /usr/bin/ls

Finding file and libraries provided by a particular package

To find all the files (binaries and library files) provided by a package, use the below command.

# rpm -ql bash
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc
/usr/bin/alias
/usr/bin/bash
/usr/bin/bashbug
/usr/bin/bashbug-64
/usr/bin/bg

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL : Move a Physical Volume from an existing Volume Group to another Volume Group
  2. dunstify: command not found
  3. How to install and configure “setroubleshootd” on CentOS/RHEL
  4. mpirun.openmpi: command not found
  5. as: command not found
  6. “yum update” fails with “[package version 1] is a duplicate with [package version 2]”
  7. aa-complain: command not found
  8. CentOS / RHEL 7 : How to configure kdump using GUI
  9. Understanding linux parted utility
  10. lrzuntar: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • raw: command not found
  • raw Command Examples in Linux
  • rankmirrors Command Examples in Linux
  • radeontop: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright