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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • 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. betterlockscreen Command Examples in Linux
  2. po4a-gettextize: command not found
  3. ac Command Examples in Linux
  4. How to merge 2 volume groups (VGs) into one using vgmerge in LVM
  5. make: Nothing to be done for `default’
  6. How to avoid ssh from prompting key passphrase for passwordless logins
  7. How to Create and Mount Btrfs Snapshots
  8. OpenLDAP Server and Client Utilities list
  9. lrztar Command Examples in Linux
  10. shutdown: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples
  • “glab mr” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright