Home > bash > Which package contains a given file?

Which package contains a given file?

The following post is based on the article “Finding which package contains a file” by Steve.


You have a file and you want to know which installed package it belongs to. Or, a program complains that some file (a .h for instance) is missing, and you want to figure out which package to install.



Search among the installed packages:

C:~> dpkg --search oggenc
vorbis-tools: /usr/share/man/man1/oggenc.1.gz
vorbis-tools: /usr/bin/oggenc
C:~> dpkg --search /usr/bin/oggenc
vorbis-tools: /usr/bin/oggenc

Search among all the available packages:

sudo apt-get install apt-file
sudo apt-file update
C:~> apt-file search ncurses.h
libncurses5-dev: /usr/include/ncurses.h
libncursesw5-dev: /usr/include/ncursesw/ncurses.h

List all the files in a package:

dpkg -L <package>


MrJamesK suggests the utility wajig, which has its own simplified command shell:

C:~> wajig
JIG> help
Common JIG commands:

 update         Update the list of downloadable 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 'wajig -v commands' for a complete list of commands.

JIG> whichpkg oggenc

File Path                                                   Package          
/usr/share/man/man1/oggenc.1.gz                             vorbis-tools     
/usr/bin/oggenc                                             vorbis-tools     
/usr/bin/oggenc                                             vorbis-tools     
/usr/lib/debug/usr/bin/oggenc                               vorbis-tools-dbg [not avr32,m68k]
/usr/lib/ripperx/ripperX_plugin-oggenc                      ripperx          
/usr/share/doc/ffmpeg-doc/html/oggenc_8c.html               ffmpeg-doc       
/usr/share/doc/ffmpeg-doc/html/oggenc_8c_source.html        ffmpeg-doc       
/usr/share/fish/completions/oggenc.fish                     fish [not hurd-i386]
/usr/share/man/man1/oggenc.1.gz                             vorbis-tools     

Wajig can be used from command-line too, you don’t need to enter its shell.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: