Posted by chantra on October 14th, 2007
apt-file is a command line tool for searching packages in Debian/Ubuntu repositories.
Unlike apt-cache search, apt-file can find files in uninstalled or can list the content of uninstalled packages.
This tutorial will show how to install apt-file, update and search or list packages and files.
Have you ever search which package contains a certain file. One could use:
dpkg -S /path/to/file
This will do the job unless the package is not yet installed.
Command line lover will love apt-file which will do the same job, but you won’t have to use your web browser.
To install apt-file, simply run:
$ apt-get install apt-file
Then we need to update apt-file database with:
$ sudo apt-file update
After some times, once the Contents files are downloaded from the repositories, you will be able to query the database for myfile or path/to/myfile with the following commands:
$ apt-file search myfile
$ apt-file search path/to/myfile
Listing the content of an uninstalled package can be done with:
$ apt-file list mypackage
Finally, you can delete the cache files with:
$ sudo apt-file purge