Open In App

How to find the rpm package of a specific file or library in CentOS/RHEL

Last Updated : 21 Aug, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Software applications designed for Linux systems are distributed in the form of packages that contain pre-compiled binaries, libraries, configuration files, and other details about the package. In the short term, it is a collection or bundle of the below files archived together. 

  1. Binary files: It is also known as executable like lscpu, cat, grep, find, etc.
  2. Documentation files:  Every program installed in Linux has man pages that would detail command syntax and the various options. Other documentation logs like README, CHANGELOGS, RELEASE NOTES, COPYRIGHT, INSTALL, and TODO, AUTHOR reside under the /usr/share/doc directory.
  3. Configuration files: It is the heart of the Linux operating system also called config file which mostly resides under /etc directory like sshd.conf, nginx.conf, httpd.conf etc.

As Linux comes pre-installed with many default packages and if the user wants to find out from which package a specific binary (like /bin/ls) configuration file (like /etc/sshd/sshd.conf) or library (like libgcc.a) got installed. There are two handy utilities (rpm and yum) to find out the package details. Using the rpm command, we can also find out all the files included in the package.

Using rpm command

RPM stands for Red Hat Package Manager which was developed by Red Hat and is used by red hat-based Linux operating systems like Fedora, CentOS, RHEL, etc. It is a popular package management tool to install, uninstall, and query individual software packages but it cannot manage dependency resolution like YUM. 

Method 1: Using –whatprovides option

Use –whatprovides option, to find out which rpm package provides a particular config file, binary, and library.

Syntax:

rpm -q --whatprovides <config_file/library/binary>

Example 1: To find out the rpm package for nginx.conf file

rpm -q --whatprovides /etc/nginx/nginx.conf
find out the rpm package for nginx.conf file

 

nginx.conf file gets installed from nginx-1.21.6-1.el7.ngx.x86_64 rpm.

Example 2: To find out the package details for library libgnutls.so.28

rpm -q --whatprovides /lib64/libgnutls.so.28
find out the package details for library libgnutls.so.28

 

Here, the library /lib64/libgnutls.so.28 is provided by gnutls-3.3.29-9.el7_6.x86_64 package.

Example 3: To find out the rpm package for the most commonly used command ls

rpm -q --whatprovides /bin/ls
To find out the rpm package for the most commonly used command ls

 

The binary ls got installed from coreutils-8.22-24.el7_9.2.x86_64 package.

Method 2: Using the -f option

There is also an alternate way to find out the rpm package using the -f option,

Syntax:

rpm -qf <config_file/library/binary>

Example 1: To find out the rpm package for nginx.conf file

rpm -qf /etc/ngingx/nginx.conf
find out the rpm package for nginx.conf file,

 

nginx.conf file gets installed from nginx-1.21.6-1.el7.ngx.x86_64 rpm.

Example 2: To find out the package details for library libgnutls.so.28

rpm -qf /lib64/libgnutls.so.28
find out the package details for library libgnutls.so.28  rpm -qf /lib64/libgnutls.so.28

 

Here, the library /lib64/libgnutls.so.28 is provided by gnutls-3.3.29-9.el7_6.x86_64 package.

Example 3: To find out the rpm package for the most commonly used command ls

rpm -qf /bin/ls
find out the rpm package for the most commonly used command ls

 

The binary ls got installed from coreutils-8.22-24.el7_9.2.x86_64 package.

Method 3: Using the yum command

YUM (Yellowdog Updater Modified) is the primary package management tool to install, update, remove, find packages, and manage packages and repositories on Linux systems. It performs dependency resolution while installing, updating, and removing software packages. Use whatprovides option, to find out the package details for the config file, library, and binary.

Syntax:

yum whatprovides <config_file/library/binary>

Example 1: To find out the rpm package for sshd_config file

yum whatprovides /etc/ssh/sshd_config
 find out the rpm package for sshd_config file

 

Here, sshd_config file is installed from openssh-server-7.4p1-21.el7.x86_64 package.

Example 2: To find out the package details for library libGL.so.1

yum whatprovides /lib64/libGL.so.1
find out the package details for library libGL.so.1

 

/lib64/libGL.so.1 got installed from libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.x86_64 package.

Example 3: To find out the rpm package for the cat command

yum whatprovides /bin/cat
find out the rpm package for the cat command

 

/bin/cat command is installed by coreutils-8.22-24.el7.x86_64 package.

Method 4: List all files and libraries provided by a particular package

Use the -l option, to find out all the files (binary/library/documentation/config file) provided by a particular package,

Syntax:

rpm -ql <package_name>

Example: To find out the config files, and libraries installed by zsh package

rpm -ql zsh

find out the config files, libraries installed by zsh package,

Here the zsh package lists all the configuration files like /etc/zlogin, /etc/zlogout, /etc/zprofile etc and libraries installed like /usr/lib64/zsh/5.5.1/zsh/clone.so, /usr/lib64/zsh/5.5.1/zsh/compctl.so, etc.

Conclusion

Thus, using the rpm and yum commands we have learned how to find out the package details from which binaries/libraries/config files got installed. This would be useful when the user wants to find out the package source.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads