apt-file is a software package that indexes the contents of packages in your available repositories and allows you to search for a particular file among all available packages.
For example, let's say you've downloaded a tarball that contains binary executables instead of source code or a deb file, but when trying to run it you receive a message telling you that a particular library file cannot be located. You can use apt-file to quickly find out which package(s) you can install in order to satisfy that dependency.
To use apt-file it must first be installed and updated. First install it using your favorite method for doing so (such as synaptic), or running, as root:
# apt-get install apt-file
After it has been installed however, it won't be of much use until it is allowed to generate a database. This can be ran as either a normal user, or as root if you want the cache to be system-wide. To generate or update the database for apt-file run:
After apt-file has been installed and the database generated, you can use it at any time to locate a file by running:
apt-file search <filename>
For example, if you needed to know which package provides the file libmp3lame.so.0, you would run:
$ apt-file search libmp3lame.so.0 libmp3lame0: /usr/lib/x86_64-linux-gnu/libmp3lame.so.0
Which tells us that to satisfy a dependency for the file libmp3lame.so.0, we need to install the package libmp3lame0 . You'll also notice that to the right of the package name in the results it tells us where the file will be installed to if you install that particular package. In the above example, by installing the package libmp3lame0 , a copy of the file we searched for, "libmp3lame.so.0" will be installed to the folder, "/usr/lib/x86_64-linux-gnu/" .
An alternative method of finding out which package provides a file is by using dpkg with the -S argument:
$ dpkg -S libmp3lame.so.0 libmp3lame0:amd64: /usr/lib/x86_64-linux-gnu/libmp3lame.so.0
Which shows us the same basic information.