How to get the files of a package on Ubuntu

December 8th, 2007
To get the list of the contents of an installed package on Ubuntu, try this command:

dpkg -L package-name

or alternatively:

dpkg --listfiles package-name

For the reverse action, that is, to find which package a file belongs to, try this command:

dpkg -S file-pattern

or alternatively:

dpkg --search file-pattern

Replace file-pattern with part of the filename you're searching for, or even the full path.

For example, we will find out which package contains the file /usr/share/java/servlet-api-2.4.jar:

giannis@giannis-desktop:~$ dpkg -S /usr/share/java/servlet-api-2.4.jar
libservlet2.4-java: /usr/share/java/servlet-api-2.4.jar


The package we're looking for, is: libservlet2.4-java

Leave a Reply