The command can only list contents of of installed packages,

dpkg -L PACKAGENAME

but how to list contents of a non-installed package, to preview/examine the package?

link|improve this question

feedback

3 Answers

up vote 15 down vote accepted

dpkg -c acts as a front-end to dpkg-deb. As such, it works directly with package archives (.deb files).

To work directly with package names rather than package files you can use apt-file.

apt-file list package_name

This works for installed and not installed packages.

apt-file package needs to be installed to use the command.

link|improve this answer
2  
apt-file also needs to be updated (sudo apt-file update), and only lists contents for packages in your already-configured Apt repositories. – quack quixote Jan 28 '10 at 22:54
@quackquixote: In Ubuntu 12.04 it's automatic – confiq May 13 at 10:43
feedback

Use --contents instead of -L:

dpkg --contents PACKAGENAME

When used in this manner, dpkg acts as a front-end to dpkg-deb, so use man dpkg-deb to see all the options.

You can also use an archive browser to view the package contents.

link|improve this answer
This doesn't work unless I installed it first and then uninstall it. – Xiè Jìléi Dec 15 '09 at 14:07
it should work fine if you give it a .deb file as an argument (instead of PACKAGENAME, give it PACKAGE-DEB-FILE). – quack quixote Dec 15 '09 at 22:11
This answer is wrong. You have to have the package installed first. If you don't have it installed, then you don't have a .deb file. – Neil May 1 at 2:14
feedback

dpkg --contents will let you look at the uninstalled package. If the .deb is not on your system yet, do

apt-get --download-only install pkgname

The package will get downloaded to /var/cache/apt/archives but not installed.

link|improve this answer
Can I just list the contents without download it? If I'm on a very slow connection, and if the package is too large to download. If the .deb file has a file header where contents list goes, I guess download the whole package maybe not necessary. Is this possible? – Xiè Jìléi Dec 15 '09 at 14:06
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.