How to find which package includes specific file

This brief outline explains how to locate specific file within Debian packages using very useful apt-file utility which as opposed to dpkg-query does not only inspect installed packages since it utilizes fetched lists of the contents of packages.

Installation

Install apt-file utility.

$ sudo apt-get install apt-offline

Update

Download current package contents according to sources.list.

$ sudo apt-file update
Perform this step periodically to always search through current package contents.

Search

Search for more or less accurately defined file.

$ apt-file search /usr/games/angband
angband: /usr/games/angband
$ apt-file search --regexp "^/usr/[a-z]*/angband$"
angband: /usr/games/angband
$ apt-file search --package-only --fixed-string "/usr/bin/newsbeuter"
newsbeuter

List

List the contents of specified package.

$ apt-file list --regexp newsbeuter$
newsbeuter: /etc/newsbeuter/config
newsbeuter: /usr/bin/newsbeuter
newsbeuter: /usr/bin/podbeuter
newsbeuter: /usr/share/doc/newsbeuter/AUTHORS
newsbeuter: /usr/share/doc/newsbeuter/README
newsbeuter: /usr/share/doc/newsbeuter/TODO.gz
newsbeuter: /usr/share/doc/newsbeuter/changelog.Debian.gz
newsbeuter: /usr/share/doc/newsbeuter/changelog.gz
newsbeuter: /usr/share/doc/newsbeuter/contrib/bookmark-delicious.sh
newsbeuter: /usr/share/doc/newsbeuter/contrib/bookmark-scuttle.sh
newsbeuter: /usr/share/doc/newsbeuter/contrib/f1sa.rb
newsbeuter: /usr/share/doc/newsbeuter/contrib/fixwesnoth.xsl
newsbeuter: /usr/share/doc/newsbeuter/copyright
newsbeuter: /usr/share/doc/newsbeuter/docbook-xsl.css
newsbeuter: /usr/share/doc/newsbeuter/examples/config.gz
newsbeuter: /usr/share/doc/newsbeuter/newsbeuter.html
[...]
newsbeuter: /usr/share/man/man1/newsbeuter.1.gz
newsbeuter: /usr/share/man/man1/podbeuter.1.gz

I need to remind that you are not limited to installed packages.

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.

Gdansk, Poland https://sleeplessbeastie.eu