How to list all files contained in a Debian package

Suppose you are trying to install a specific deb package, but want to know what files are contained in the package before actual installation. Or imagine that you are not sure what package owns a specific program binary or library you need.

In these cases, it will be useful if you can check the content of a specific deb package before installation. This article tells you how to do it.

In Ubuntu or Debian, there are two ways to show all files contained in a particular deb package without installing it.

Method One

The first method is to use apt-file command-line tool.

To install and use apt-file on Ubuntu or Debian, do the following.

$ sudo apt-get install apt-file
$ sudo apt-file update

Note that you need to run "apt-file update" at first, in order to synchronize all available package contents from their sources.

Then to show files belonging to a specific deb package (e.g., tofrodos), simply run:

$ sudo apt-file show tofrodos
tofrodos: /usr/bin/fromdos
tofrodos: /usr/bin/todos
tofrodos: /usr/share/doc/tofrodos/NEWS.Debian.gz
tofrodos: /usr/share/doc/tofrodos/changelog.Debian.gz
tofrodos: /usr/share/doc/tofrodos/copyright
tofrodos: /usr/share/doc/tofrodos/readme.txt.gz
tofrodos: /usr/share/doc/tofrodos/tofrodos.html
tofrodos: /usr/share/man/man1/fromdos.1.gz
tofrodos: /usr/share/man/man1/todos.1.gz

The output will show the names of all contained files, along with their respective target installation directories.

Method Two

The second method to show files in a Debian package is to use apt-get command, but with "--download-only" option.

$ apt-get --download-only install tofrodos

Once you run the above command, a deb package called tofrodos will get downloaded to /var/cache/apt/archives, but will not be installed.

Then you can use dpkg command to list contents of the locally downloaded deb package.

$ dpkg -c /var/cache/apt/archives/tofrodos_1.7.9.debian.1-1build1_amd64.deb
drwxr-xr-x root/root         0 2011-10-18 10:47 ./
drwxr-xr-x root/root         0 2011-10-18 10:47 ./usr/
drwxr-xr-x root/root         0 2011-10-18 10:47 ./usr/share/
drwxr-xr-x root/root         0 2011-10-18 10:47 ./usr/share/man/
drwxr-xr-x root/root         0 2011-10-18 10:47 ./usr/share/man/man1/
-rw-r--r-- root/root      1677 2011-10-18 10:47 ./usr/share/man/man1/fromdos.1.gz
drwxr-xr-x root/root         0 2011-10-18 10:47 ./usr/share/doc/
drwxr-xr-x root/root         0 2011-10-18 10:47 ./usr/share/doc/tofrodos/
-rw-r--r-- root/root       391 2011-10-18 10:47 ./usr/share/doc/tofrodos/NEWS.Debian.gz
-rw-r--r-- root/root      1406 2011-10-18 10:47 ./usr/share/doc/tofrodos/copyright
-rw-r--r-- root/root      5832 2011-02-27 04:25 ./usr/share/doc/tofrodos/tofrodos.html
-rw-r--r-- root/root      3746 2011-10-18 10:47 ./usr/share/doc/tofrodos/changelog.Debian.gz
-rw-r--r-- root/root      5410 2011-02-27 04:25 ./usr/share/doc/tofrodos/readme.txt.gz
drwxr-xr-x root/root         0 2011-10-18 10:47 ./usr/bin/
-rwxr-xr-x root/root     12792 2011-10-18 10:47 ./usr/bin/fromdos
lrwxrwxrwx root/root         0 2011-10-18 10:47 ./usr/share/man/man1/todos.1.gz -> fromdos.1.gz
lrwxrwxrwx root/root         0 2011-10-18 10:47 ./usr/bin/todos -> fromdos

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.
Your name can also be listed here. Write for us as a freelancer.

Leave a comment

Your email address will not be published. Required fields are marked *