A A
RSS

Find Which Package owns a File in Linux

Sat, Jun 26, 2010

Tweet this!

Sometimes it is necessary to find out which package is responsible for a particular file on a Linux machine. This article explains how to identify the package that owns a file on Ubuntu or Fedora Linux (it applies to any distribution using deb or RPM, so it will also work in Debian, RedHat, etc…)

Deb-based Distributions: Debian, Ubuntu, etc..

To identify the package that owns a file in Ubuntu or other deb-based distributions, you want to use the dpkg-query command with the -S option, in the form: dpkg-query -S /path/to/file

So, for example, if you wanted to find the owner of /usr/bin/gst-feedback-0.10, your terminal should appear as:

jdeprizi@orion:~$ dpkg-query -S /usr/bin/gst-feedback-0.10
gstreamer0.10-tools: /usr/bin/gst-feedback-0.10
jdeprizi@orion:~$
RPM-based Distributions: Fedora, RedHat, etc..

Similarly, you can find the RPM that owns or installed a file in Fedora or RedHat with the rpm -qf command. Here is an example:

[jdeprizi@pioneer ~]$ rpm -qf /usr/bin/gst-feedback-0.10
gstreamer-0.10.29-1.fc13.i686
[jdeprizi@pioneer ~]$
A quick caveat

For either of these commands to work, the package owning the file must be installed. This is necessary because the ownership needs to be registered with the package manager.

Like this post?

3 Responses to “Find Which Package owns a File in Linux”

  1. maidis says:

    PiSi-based Distributions: Pardus…

    Similarly, Pardus has a search-file command with file-name parameter is used in order to find which package does a file belong to.

    $ pisi sf -q /usr/bin/gst-feedback-0.10
    Package gstreamer has file /usr/bin/gst-feedback-0.10
    $

  2. JK Wood says:

    In Slackware, it’s pretty simple as well -

    $ grep usr/bin/gst-feedback-0.10 /usr/bin/gst-feedback-0.10 /var/log/packages/*
    /var/log/packages/gstreamer-0.10.29-x86_64-1:usr/bin/gst-feedback-0.10
    $

  3. Joe Wahoo says:

    On a system using yum, such as fedora, you can use repoquery in the same manner as rpm — the only difference is now the package doesn’t need to be isntalled, just available in one of the repositories.

Leave a Reply

Subscribe

Weekly Poll

What do you think of Google Chrome?

View Results

Loading ... Loading ...

Advertisement

Search TechThrob