Is there an apt command to download a deb file from the repositories to the current directory?

You can use the download sub-command of apt, apt-get or aptitude. For example, if $PKG is the package you want, any of these will do:

apt-get download $PKG
apt download $PKG
aptitude download $PKG

This doesn't require root privileges. The same can also be approximated using apt-get and wget:

wget $(apt-get install --reinstall --print-uris -qq $PKG | cut -d"'" -f2)

This will, however, fetch all packages required to install the package, so you can attempt to limit it instead:

wget $(apt-get install --reinstall --print-uris -qq $PKG | cut -d"'" -f2 | grep "/${PKG}_")

You can also put a wget line into a function, to be able to use it as a command apt-download with the package name as a parameter:

function apt-download { wget -c $(apt-get install --reinstall --print-uris -qq $1 | cut -d"'" -f2); }

Note the modifications: The $PKG is replaced with $1 and the -c parameter enables continuing interrupted downloads.


sudo apt-get -o dir::cache::archives="/path/to/folder/" -d install package

Note:

You need to create an folder named partial in destination folder.


In Ubuntu 14.04 (apt package version 1.0.1ubuntu2, I believe), apt-get includes the download command to download the given package as a .deb in the current directory.

For example, suppose we want to download the file manager Ranger:

$ apt-get download ranger

Results in:

$ ls . | grep ranger
ranger_1.6.0-1_all.deb