128

I have a computer without a NIC, and I want to install some programs in it via USB memory, but how can I download a program from apt-get without installing it?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Manuel de Leon
  • 2,623
  • 4
  • 19
  • 12
  • 6
    This can be moved to SuperUser, right? – kumarharsh Feb 13 '15 at 07:28
  • 2
    Or to [AskUbuntu](https://askubuntu.com), where it has since been [asked](https://askubuntu.com/questions/47865/how-do-i-use-apt-get-to-only-download-packages) and [answered](http://askubuntu.com/a/47877/20358). – jpaugh Jan 26 '17 at 15:13
  • For Debian start https://packages.debian.org/stable/ Drill down. Very near (way down) the page for the package is a list of architectures you can download. Click to download. – Elliptical view Jun 23 '20 at 23:23

3 Answers3

136

Try

apt-get -d install <packages>

It is documented in man apt-get.

Just for clarification; the downloaded packages are located in the apt package cache at

/var/cache/apt/archives
Zombo
  • 1
  • 62
  • 391
  • 407
Marcus Borkenhagen
  • 6,536
  • 1
  • 30
  • 33
  • 4
    Does this work if the package is already up-to-date on the system which `apt-get -d` is executed on? – Peter Mortensen Jul 25 '14 at 13:49
  • @PeterMortensen, nope it does not. But in this case you could use dpkg-repack (apt-get install dpkg-repack + man should be easy enough) - although this is quite far-fetched in relation to the original question. Alternatively there is always http://packages.debian.org/ – Marcus Borkenhagen Jul 26 '14 at 12:29
126

There are a least these apt-get extension packages that can help:

apt-offline - offline apt package manager
apt-zip - Update a non-networked computer using apt and removable media

This is specifically for the case of wanting to download where you have network access but to install on another machine where you do not.

Otherwise, the --download-only option to apt-get is your friend:

 -d, --download-only
     Download only; package files are only retrieved, not unpacked or installed.
     Configuration Item: APT::Get::Download-Only.
Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
53

Don't forget the option "-o", which lets you download anywhere you want, although you have to create "archives", "lock" and "partial" first (the command prints what's needed).

apt-get install -d -o=dir::cache=/tmp whateveryouwant
knocte
  • 16,941
  • 11
  • 79
  • 125
Alfonso Vila
  • 539
  • 3
  • 2
  • 11
    If you're running as a non-root user you can do something like: mkdir -p /tmp/archives/partial && apt-get -d -o dir::cache=/tmp -o Debug::NoLocking=1 install package –  May 22 '12 at 16:56
  • +1 for mentioning -o option. Was searching for this information for almost an hour now. – Hashken Jul 21 '12 at 04:26
  • 3
    On 12.04, when I ran: ``apt-get -d -o=dir::cache=/tmp/pkg rabbitmq-server E: Invalid operation rabbitmq-server`` It should be : ``$ apt-get download -o=dir::cache=/tmp/pkg rabbitmq-server Get:1 Downloading rabbitmq-server 2.7.1-0ubuntu4 [2,745 kB] 13% [1 rabbitmq-server 361 kB/2,745 kB 13%]`` – HVNSweeting Jun 25 '13 at 03:47
  • 5
    This doesn't appear to download anything if the package is already up-to-date on the system. – Sparhawk Sep 06 '15 at 23:50
  • 1
    you need to include the "install" command in the request. Thus "apt-get install -d -o=dir::cache=/tmp packagename" – Paul Chernoch Dec 09 '16 at 17:17
  • I need the -o option, without the system does not download the packages. – Scorpion Jan 25 '20 at 10:57