The ‘rpm -q -f’ command can be used to identify RPM to which an installed file belongs to. The following example queries RPM database to find the RPM that own /usr/bin/kompare file.

[neo@techpulp ~]# rpm -q -f /usr/bin/kompare
kdesdk-3.5.8-2.fc8
[neo@techpulp ~]#

If the file doesn’t belong to any RPM it displays a message as shown below.

[neo@techpulp ~]# rpm -q -f /home/neo/myfile.txt
file /home/neo/myfile.txt is not owned by any package
[neo@techpulp ~]#