How to list all files contained in a Debian package

Last updated on June 17, 2013 by Dan Nanni

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: apt-file

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: apt-get

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

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean