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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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. Understanding iscsiadm Utility in CentOS / RHEL
  2. Unable To Remove Files From Directory with Error “Argument list too long”
  3. 6 Bash Shell Command Line Chaining Operators in Linux
  4. Ubuntu: Changing the stripe size of a striped LVM volume
  5. How to use command redirection under Linux
  6. How to list all modules and check if they are enabled or disabled in CentOS/RHEL 8
  7. Understanding kdump Configuration file /etc/kdump.conf
  8. Installing CentOS / RHEL 7 (step by step with screen shots)
  9. Bash for loop Examples
  10. “mlock failed: Cannot allocate memory” lvcreate command error in CentOS/RHEL 7

You May Also Like

Primary Sidebar

Recent Posts

  • How to disable ACPI in CentOS/RHEL 7
  • How to Use real-time query to access data on a physical standby database
  • CentOS/RHEL 8: “ACPI MEMORY OR I/O RESET_REG” Server Hung after reboot
  • How to Create a Physical Standby Database by Using SQL and RMAN Commands
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary