On Linux operating systems that use the APT package management system, the apt-file command searches available packages for a specific file or files. The packages do not need to be installed to perform the search.

Description

The apt-file tool can list, and search for, individual files in the software packages used by APT. It’s similar to using dpkg -L, but apt-file can search all available packages, not just the ones already installed. It accomplishes this by maintaining a local cache of package contents.

  • Description

  • Installing apt-file

  • Syntax

  • Actions

  • Options

  • Examples

  • Relevant files and directories

  • Related commands

  • Linux command index

  • Actions

  • Options

Installing apt-file

If apt-file is not already installed on your system, you can install it with the command:

sudo apt update && sudo apt install apt-file

After installation, you will receive a message about creating the apt-file cache:

The system-wide cache is empty. You may want to run ‘apt-file update’ as root to update the cache. You can also run ‘apt-file update’ as normal user to use a cache in the user’s home directory.

You may also receive a notification window:

To update your user cache, you can click Run this action now, and then Close.

Or, in a terminal you can run:

sudo apt-file update && apt-file update

To update both the system-wide cache and your user cache.

When the update is complete, you are ready to use apt-file.

Syntax

apt-file [options] [action] [pattern]

apt-file -f [options] search [file…]

apt-file -D [options] search [debian-package-name.deb…]

Actions

Options

Examples

apt-file purge

Purge the user cache. An apt-file update will be needed before a search can be performed on the user cache. If the user cache doesn’t exist, the system-wide cache can be used for user searches.

apt-file update

Download information from sources, and create or update the user cache.

sudo apt-file purge

Purge the system-wide cache. sudo apt-file update is required before the systemwide cache can be used.

sudo apt-file update

Download information from sources, and create or update the system-wide cache.

apt-file search gimp

Show every file with “gimp” in its name, in every available APT package.

apt-file –package-only search gimp

Perform the same search as above, but list only the names of matching packages.

apt-file list gimp

List every file contained in every package with “gimp” in its name.

apt-file –package-only list gimp

Perform the same search as above, but list only the matching package names. Running this command provides output similar to apt-cache –names-only search gimp.

Relevant files and directories

apt — A unified APT front end for the command line.apt-cache — Get information about installed and available APT software packages.apt-get — Download and install APT software packages.apt-cache — Change the settings of individual APT software packages.aptitude — An enhanced APT front end for the terminal.dpkg — Install, remove, and maintain Debian software packages.