How to find a specific file belongs to which RPM or DPKG package on linux systems.
On Linux systems ( RPM or Debian), We would often require to find out to which package the target file belongs on the system. This can be found by using following set of commands on the system.
On RPM based systems :
When we execute the rpm -qf command to find out which package the file belongs ( as shown in the example below)
rpm -qf /etc/protocols
The /etc/protocols file belongs to package "setup-2.8.14-20.el6_4.1.noarch" on SLES 11 Sp3.
On Debian based systems :
When we execute the dpkg -S command to find out which package the file belongs ( as shown in the example below)
#dpkg -S /etc/protocols
The /etc/protocols file belongs to package "netbase" in ubuntu 14.04/
We can also use the below method to find the about the package information the file belongs on ubuntu (debian) systems.
apt-file search filename
apt-file search /etc/protocols
Note : To install apt-file use :
sudo apt-get install apt-file and we
need to update its database
before you can use it
by executing sudo apt-file update