List of files installed from apt package

Solution 1:

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

Solution 2:

dpkg -S /path/to/file/in/question

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

Solution 3:

Here is a function that should do it for you without the need to downloading the package to disk.

apt_list () 
{ 
    local packages=("$@");
    for pkg in $(seq 0 1 $((${#packages[@]}-1)));
    do
        echo -e "\n#### ${packages[$pkg]} ####\n";
        apt-get download -o Dir::Cache::archives="./" --print-uris ${packages[$pkg]} | awk -F\' '{print $2}' | xargs -I '{}' curl -skL '{}' | dpkg-deb -c /dev/stdin | perl -ne 's,(:\d\d )[.]/,$1/,g;print';
        echo;
    done
}

Then use apt_list <package name1> [package name 2]

e.g. apt_list curl wget

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