Apt-file
What is apt-file?
apt-filequeries the Debian package database to locate files contained in packages.- Unlike
dpkg -L, which only works for installed packages,apt-filecan search all available packages in the repositories. -
Helps find:
-
Which package provides a particular executable, library, or config file.
- Files in development packages (
-dev) for compiling software. - Missing headers or libraries when compiling from source.
Installation
This downloads the latest database of files in packages from the repositories.
How to Use apt-file
1. Search for a File Across All Packages
Example:
- Lists all packages that provide
/usr/bin/git.
2. List Contents of a Package (Even If Not Installed)
Example:
- Shows all files installed by the
curlpackage.
3. Update the apt-file Database
- Must be done periodically to get the latest repository information.
4. Search with Wildcards or Patterns
- Useful for locating libraries, headers, or other files using patterns.
5. Advanced Usage
- Search only installed packages:
- Search for executables in PATH using apt-file:
- Combine with grep for filtering:
Practical Examples
- Finding Development Headers
-
Tells you which
-devpackage containszlib.hso you can install it for compilation. -
Troubleshooting Missing Binaries
-
If
htopisn’t installed, you’ll see which package provides it (htoppackage). -
Locating Configuration Files
- Shows which package provides the configuration file.