Every once in a while I need to know which files were installed as part of a given package of a dpkg-based distro such as Debian, Ubuntu, etc.

Here is how:

$ dpkg-query --listfiles <package-name>


gmacario@dc7600-gm:~$ dpkg-query --listfiles lxc-docker

or the other way round, i.e. finding out which Ubuntu package has installed some file in my filesystem.

$ dpkg-query --search <filename>

Example 1:

gmacario@dc7600-gm:~$ dpkg-query --search /bin/ls
coreutils: /bin/ls

Reference: man dpkg-query