How can I check dependency list for a deb package

How can I check dependency list for a deb package. I am running Ubuntu 11.10 and I have backed up all deb packages from var/cache/apt/archives. I want to format my pc and re-install selected applications only. Also how can I get the list of installed packages and dependencies.


This will show you all the information about the package:

dpkg -I package.deb

In addition to the dpkg method, you can check the dependencies of packages in the repository:

apt-cache depends package-name

EDIT Updated with @Tino's recommendation. @Tigran's comment no longer applies.


depends VS rdepends

  • apt-cache depends package-name
    //show package-name depends on who

  • apt-cache rdepends package-name
    //show who depends on package-name

depends

$ apt-cache depends vim-runtime
vim-runtime
  Breaks: vim-tiny
 |Recommends: vim
    vim-athena
    vim-gtk
    vim-gtk3
    vim-nox
 |Recommends: vim-gtk
 |Recommends: vim-gtk3
 |Recommends: vim-athena
 |Recommends: vim-nox
  Recommends: vim-tiny
  Enhances: vim-tiny

rdepends

$ apt-cache rdepends vim-runtime
vim-runtime
Reverse Depends:
  vim
  vim
  vim-nox
  vim-gtk
  vim-athena
  vim-gtk3
  vim
  vim-nox
  vim-gtk
  vim-athena
  vim-gtk3

For 14.04 and later:

dpkg doesn't have the -I any more and you have to use dpkg-deb to show package information including dependencies:

dpkg-deb -I package.deb

apt-cache depends [Package-Name] will work as well. Although if you source the .deb package from outside your sources list, things like apt-cache showpkg [Package-Name] && apt-cache depends [Package-Name] might show outdated info or might not sync with the actual installed package hence dpkg -I [Package-Name] would work best in that case.