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
| improve this answer | |
  • 5
    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
  • $ dpkg -L package not $ dpkg -L $package putting the $ in front of the package names returns an error – Alecz Jan 14 '17 at 21:50
  • 1
    The dollar is meant to be understood as a variable, meaning you need to replace $package with the actual name of the package. – ℝaphink 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
dpkg -S /path/to/file/in/question

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

| improve this answer | |
  • 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.

| improve this answer | |

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.