Ubuntu – How to download .deb package and all dependencies

aptpackage-managementUbuntu

For all answers i found about this topic, the solution was to create, in a certain computer A where i need to install the package, a file containing all dependencies it needs and then downloading it in another computer, let's call it B.

The thing is, i want to have a storage of certain critical software i need to work to be able to install them offline later on in case i have to format my desktop.

I REALLY DON'T CARE about having a lot of redundant .deb files in my computer, and I REALLY DON'T CARE if i'm going to store 1gb of files to install a 10mb software.

So, i want to have any possible dependency downloaded. Is there someway i can do this?

Best Answer

I would go with this:

apt-cache depends -i PACKAGE | awk '/Depends:/ {print $2}' | xargs apt-get download && apt-get download PACKAGE

Then you can install it with dpkg -i *.deb in the directory you downloaded these.