How-To: Find missing packages with apt-file

1 minute read

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.

Hopefully, both Debian and Ubuntu have a package repository, http://packages.debian.org/ and http://packages.ubuntu.com.

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

or

$ 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