October 26, 2007

Debian: HOWTO find a package containing a certain file

Debian: HOWTO find a package containing a certain file

(this example works on Debian-based systems too):

# apt-file update && apt-file search /usr/share/doc/rails/README.railties
rails: usr/share/doc/rails/README.railties
#


This example was me searching a package containing /usr/share/doc/rails/README.railties file. The result tells that rails is the package.

4 comments:

  1. Well.. if the file is inside /usr/share/doc/[package name]/*, you know already that the package name is called [package name]. ;)

    The real power of apt-file is that you can simply search for the file, without the folder part, like:

    $ apt-file search README.railties
    rails: usr/share/doc/rails/README.railties

    ReplyDelete
  2. Anonymous1:34 PM

    Didn't know this one. I had to install apt-file in Debian Lenny GNU/Linux, and know I'm waiting for it to "apt-file update".
    It might come in hand :)

    ReplyDelete
  3. Anonymous2:57 PM

    If the file you're looking for belongs to a package that is installed, you can also use dpkg directly:

    $ dpkg -S /etc/crontab
    cron: /etc/crontab

    ReplyDelete
  4. b.r.: Oops, my mistake... That was exactly the example I wanted to give :-P Thanks...

    Manuel: Yes, I just posted this one 'cause many people ask me how to do it with non-installed packages... But thanks anyway :-)

    ReplyDelete