How to install only the dependencies of a package?

This will install all packages in the package's Depends and PreDepends field:

sudo apt-get install $(apt-cache depends <PACKAGE> | grep Depends | sed "s/.*ends:\ //" | tr '\n' ' ')

Basically you ask for all dependencies, filter out the (Pre)Depends, and format that output for apt-get.

One problem are dependencies like

Depends: pulseaudio
  pulseaudio:i386

or virtual packages like

Depends: <java6-runtime-headless>
  default-jre-headless
  openjdk-6-jre-headless

So: use with care - it doesn't work in all cases!


If you don't mind copy/past, just simulate an apt-get install with -s. That way you will see which other packages will get installed and/or upgrade, then you just remove the package name you don't want to install from that list and voila.

sudo apt-get install -s <package>


apt-get build-dep <package> will do the trick.