Tuesday, December 11, 2012

[HOW TO] Find which package includes a specific file

apt-file is a command that allows you to find which package includes a specific file. It can also be used to list all files included in a package without installing or downloading it.

Install

Open a terminal window and run:

sudo apt-get install apt-file -y && sudo apt-file update

The last part of the above command will update apt-file's cache, so it might take a few minutes to complete.

Usage

The updated cache can be queried for a list of packages containing a file. The query may be constructed using only the file's name or the file's path:

apt-file search filename
apt-file search path/to/filename

The contents of a package can be listed with:

apt-file list packagename

References

apt-file | manpage

4 comments:

  1. Very useful! i used Y PPA Manager in ubuntu but i didnt try it since i installed xubuntu. Thanks!

    ReplyDelete
  2. Hi,
    dpg-query already do this.
    For example:

    $ dpkg-query -S /usr/bin/xfce4-terminal
    --> xfce4-terminal: /usr/bin/xfce4-terminal

    Cheers.

    ReplyDelete