Share this post with your friends
At times you need to know which package contains a specific file on rpm based Linux distros such as Fedora, RedHat(RHEL), CentOS, openSUSE, SLE etc. Read below to learn how.
Let's say you want to know what package provides the
ip command. It's a two step process.
Finding the location of the ip binary:
To find the
ip binary location, run the following command.
The location is
/sbin/ip as it's seen from the output of
Finding the package name with rpm:
To find the package that contains the binary
/sbin/ip, run the following command.
rpm -qf /sbin/ip
From the output of
rpm command, you can see that the package is
iproute-3.10.0-54.el7.x86_64. So this is the package that we were looking for.
You can use any file path with
rpm -qf command. As long as the rpm database knows about the file. You will get a result.
Tested on: CentOS 7