Google+ Linux How-To: Downloading .deb Packages with Apt in Userspace, even if already installed | Janne P. Hukkinen | Blog
Log in or Sign Up

Linux How-To: Downloading .deb Packages with Apt in Userspace, even if already installed

June 10, 2012, 1:55 p.m.
Author: HUKKINEN

Linux How-To: Downloading .deb Packages with Apt in Userspace, even if already installed

Tech stuff. In case you ever need to download .deb packages using Apt package-manager even though you a) are not root in the system or b) have the package already installed, here is the cure.

First, define a bash function by copy-pasting this "one-liner" on the command-line or in your ~/.bashrc initialization script:


function apt-download { \
apt-get --print-uris -d install --reinstall $1 -y -q | \
cut -d"'" -f2 | \
egrep '^(cdrom|file|http|ftp|copy|ssh|rsh)' | \
xargs wget -c; }


Then, run it with the package name as a parameter like this:

apt-download PACKAGE-NAME

The script extracts the URIs of the package( and its dependencie)s and (resume-)downloads them with wget (as far as wget supports the same listed URI types as Apt; http and ftp repositories should work fine). The script does not need aptitude but if the system has it installed, the simplest way is to:

aptitude download PACKAGE-NAME

A couple of more simple variations here.

Häve fun!