• 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. mkfs.ext4 Command Examples in Linux
  2. btrfs inspect-internal Command Examples in Linux
  3. cmark: Converts CommonMark Markdown formatted text to other formats
  4. e2undo: command not found
  5. isisdl Command Examples
  6. setxkbmap Command Examples in Linux
  7. hsd-cli Command Examples
  8. composer-require-checker: A CLI tool to analyze Composer dependencies for soft dependencies
  9. equery Command Examples in Gentoo Linux
  10. grub-mkconfig Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright