How do I get a list of files that were or will-be installed when I apt-get a package? Conversely, can I find what package(s) caused a particular file to be installed?


Note: in the following commands, a command beginning with 'root#' means it needs to be run as root.

To find which files were installed by a package, use dpkg -L:

$ dpkg -L $package

apt-file can tell you which files will be installed by a package before installing it:

root# apt-get install apt-file
root# apt-file update
$ apt-file list $package

Or if you have the package as a .deb file locally already, you can run dpkg on it:

$ dpkg --contents $package.deb

To find which package provides a file that is already on your system, use:

$ dpkg -S /path/to/file

To find which package provides a file that is not currently on your system, use apt-file again:

$ apt-file search /path/to/file
  • 7
    Keep in mind that while this will get you most of what you need it will not give you everything. Several packages create configuration files as part of their setup scripts. These files will not be reported by dpkg. – Zoredache Dec 23 '09 at 17:33
  • 2
    The dollar is meant to be understood as a variable, meaning you need to replace $package with the actual name of the package. – raphink Jan 15 '17 at 23:37
  • 1
    conffiles of a package (if any) are listed by command dpkg --status $package. For the reverse operation use grep $filename /var/lib/dpkg/info/*.conffiles. – Uwe Geuder Mar 8 '18 at 17:38
  • 1
    bit late Q - - what does sudo apt-file update do ?? – samshers Aug 21 '20 at 10:01
  • 1
    @samshers, apt-file update command populates the db which apt-file uses for searches. – Victor Yarema Oct 28 '20 at 19:49
dpkg -S /path/to/file/in/question

As far as I'm concerned, dpkg is the low-level tool that apt-get depends on.

  • Yes, dpkg is the command that adds and removes software and files from you mcomputer. apt (incl. Apt-get, aptitude, synaptic, etc.) is the programme that calls dpkg – Rory May 9 '10 at 12:06

If you have installed dlocate, you can use dlocate -L the same way as dpkg -L. It works exactly the same in this case, but has a number of other options.


Here is a function that should do it for you.

apt_list () 
     apt-get download -o Dir::Cache::archives="./" --print-uris "$@" |awk -F\' '{print $2}' | xargs -I '{}' curl -skL '{}' | dpkg-deb -c /dev/stdin

Then use apt_list <package name>

As for reverse checking files from packages apt-file would be the best bet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.