Find which package contains a file in Debian Linux

If you know you need to find a particular file to finish a compilation And you don't know which package it is contained in.You have the following option in debian.


APT package searching utility -- command-line interface

apt-file is a command line tool for searching packages for the APT packaging system.

Unlike apt-cache, you can search in which package a file is included or list the contents of a package without installing or fetching it.

Install apt-file in debian

#apt-get install apt-file

this will install the apt-file package now.

Once installed you'll need to download the actual data which it uses to search. This can be accomplished with the following command otherwise apt-file search command won't return any results.

#apt-file update

Once you've downloaded data you can now proceed to searching for packages.

#apt-file [options] action [pattern]

Configuration options:
   --sources-list      -s  <file>      sources.list location
   --cache             -c  <dir>       Cache directory
   --architecture     -a  <arch>     Use specific architecture
   --cdrom-mount    -d  <cdrom>   Use specific cdrom mountpoint
   --package-only    -l               Only display packages name
   --fixed-string       -F              Do not expand pattern
   --ignore-case       -i              Ignore case distinctions
   --regexp              -x              pattern is a regular expression
   --verbose            -v              run in verbose mode
   --dummy             -y              run in dummy mode (no action)
   --help                 -h              Show this help.
   --version             -V              Show version number

   update                          Fetch Contents files from apt-sources.
   search      <pattern>       Search files in packages
   list           <pattern>       List files in packages
   purge                            Remove cache files


#apt-file search

libapache-mod-perl: usr/lib/perl5/
libapache2-mod-perl2: usr/lib/perl5/Apache2/
libembperl-perl: usr/lib/perl5/
libembperl-perl: usr/lib/perl5/Embperl/Recipe/
libembperl-perl: usr/lib/perl5/Embperl/Syntax/
libhtml-embperl-perl: usr/lib/perl5/HTML/
liblog-log4perl-perl: usr/share/perl5/Log/
libsdl-perl: usr/lib/perl5/
perl-modules: usr/share/perl/5.8.4/ExtUtils/

You can also use one of the following commands to Finding which package contains a file.

#dpkg -L <package name>


fast alternative to dpkg -L and dpkg -S

uses GNU locate to greatly speed up finding out which package a file belongs to (i.e. a very fast dpkg -S). many other uses, including options to view all files in a package, calculate disk space used, view and check md5sums, list man pages, etc.

Install dlocate in debian

#apt-get install dlocate

Usage: dlocate [option] [string...]

   (no option) string  list all records that match
   -S        string      list records where files match
   -L        package     list all files in package
   -l        package     almost-emulation of 'dpkg -l'
   -s        package     print package's status
   -ls       package     'ls -ldF' of all files in package
   -du       package     'du -sck' of all files in package
   -conf     package     list conffiles in package
   -lsconf   package     'ls -ldF' of conffiles in package
   -md5sum   package     list package's md5sums (if any)
   -md5check package     check package's md5sums (if any)
   -man      package     list package's man pages (if any)

 The -L, -s, and -S commands are roughly analagous to the equivalent dpkg commands.


#dlocate -S /etc/bash_completion

bash: /etc/bash_completion.d
bash: /etc/bash_completion
ppp: /etc/bash_completion.d
ppp: /etc/bash_completion.d/pon
dpatch: /etc/bash_completion.d
dpatch: /etc/bash_completion.d/dpatch_edit_patch
module-assistant: /etc/bash_completion.d
module-assistant: /etc/bash_completion.d/m-a


simplified Debian package management front end

Wajig is a single commandline wrapper around apt, apt-cache, dpkg, /etc/init.d scripts and more, intended to be easy to use and providing extensive documentation for all of its functions.

With a suitable sudo(1) configuration, most (if not all) package installation as well as creation tasks can be done from a user shell. Wajig is also suitable for general system administration.

A Gnome GUI command 'gjig' is also included in the package.

Install wajig in Debian

#apt-get install wajig

Using wajig


JIG> help
Common JIG commands:

 update         Update the list of down-loadable packages
 new             List packages that became available since last update
 newupgrades    List packages newly available for upgrading
 install             Install (or upgrade) one or more packages or .deb files
 remove          Remove one or more packages (see also purge)
 toupgrade      List packages with newer versions available for upgrading
 upgrade        Upgrade all of the installed packages or just those listed
 listfiles         List the files that are supplied by the named package
 listnames      List all known packages or those containing supplied string
 whatis          For each package named obtain a one line description
 whichpkg       Find the package that supplies the given command or file

Run LIST-COMMANDS for a complete list of commands.


JIG> whichpkg alsamixer
File Path                                                   Package
===========================================================-===== ============
/usr/bin/alsamixer                                          alsa-utils
/usr/share/doc/alsa-utils/README.alsamixer        alsa-utils
/usr/share/man/man1/alsamixer.1.gz                  alsa-utils


package search by file and on-demand package installation tool

auto-apt checks the file access of programs running within its environments, and if a program tries to access a file known to belong in an uninstalled package, auto-apt will install that package using apt-get. This feature requires apt and sudo to work.

It also provides simple database to search which package contains a requesting file.

Install auto-apt in Debian

#apt-get install auto-apt

After installing you need to update the package list using the following command

#auto-apt update

If you want to use auto-apt follow this syntax


$Id:,v 1.58 2004/03/19 17:53:25 ukai Exp $
Usage: auto-apt [options] command [arg ...]

auto-apt is a simple command line interface for setting up auto-apt ennvironment and/or search packages by filename.

   run - Enter auto-apt environment run [command [cmdarg]]
   update - Retrieve new lists of Contents (available file list) update
   updatedb - Regenerate lists of Contents (available file list, no download) updatedb
   update-local - Generate installed file lists update-local
   merge - Merge lists of Contents merge
   del - Delete package list del package
   check - Check which package will provide the filename check [-v] [-f] filename list - List filelist in dbfile list [-v] [-f]
   search - Search package by filename (grep) search [-v] [-f] pattern
   debuild - debuild with auto-apt useful to get build-depends:
   status - Report current environments (auto-apt or not)

 For some commands, command name with -local suffix, it will use pkgfiles.db, which is created by update-local command, instead of  pkgcontents.db

   [-s] [-y] [-q] [-i] [-x] [-X]
   [-a dists] [-p hooks]
   [-D pkgcontents.bin] [-F pkgfiles.bin] [-L detect.list]


#auto-apt search alsamixer

usr/lib/menu/gnome-alsamixer    gnome/gnome-alsamixer
usr/lib/menu/alsamixergui       sound/alsamixergui
usr/bin/gnome-alsamixer gnome/gnome-alsamixer
usr/bin/alsamixergui    sound/alsamixergui
usr/bin/alsamixer       sound/alsa-utils
usr/share/pixmaps/gnome-alsamixer/      gnome/gnome-alsamixer
usr/share/doc/alsamixergui/     sound/alsamixergui
usr/share/doc/gnome-alsamixer/  gnome/gnome-alsamixer