24

Apt (Advanced Packaging Tool) has option to download only package by apt-get -d install [pkg-name]. I have also find apt-get download [pkg-name] to download packages.

Then what is the difference between --download-only (apt-get -d install)and download (apt-get download)?

And When should I use between them?

Pandya
  • 35,771
  • 44
  • 128
  • 188

3 Answers3

29

I could list following:

  1. Try both without sudo, apt-get download will pass and apt-get -d install will fail (root required)

  2. By default apt-get -d install will save .deb in /var/cache/apt/archives and apt-get download in current directory

  3. apt-get download is newer, you wouldn't even find it in the old versions.

From man page:

download download will download the given binary package into the current directory.

-d, --download-only Download only; package files are only retrieved, not unpacked or installed. Configuration Item: APT::Get::Download-Only.

Pablo Bianchi
  • 15,657
PradyJord
  • 566
11

The --download-only switch needs to be accompanied by another command, be it install, upgrade or whatever command would require to download package. If you don't need to download packages, is plain as day that it wouldn't download anything. --download-only restricts apt actions to just downloading the packages that it needs into the cache directory, nothing more. If your operation would end into downloading dependencies it will download them for you.

Since it needs a command like install or upgrade it normally would require sudo or root permissions, since the default directory used to download the packages is owned by root.

The download command is standalone, it reads the package list and download only the package specified, it doesn't download dependencies nor other packages. It doesn't require root permissions if you can write your current directory, this wouldn't store the files in the package cache directory.

Pandya
  • 35,771
  • 44
  • 128
  • 188
Braiam
  • 67,791
  • 32
  • 179
  • 269
  • something doesn't make sense here. install --download-only has the word "install" in it, but does NOT install actually? – aderchox Aug 09 '20 at 11:57
6

Use the man command :)

apt-get download will download the package, but not its dependencies, to the current directory.

apt-get -d install will download the given package and all missing dependencies to the system packages directory (/var/cache/apt/archives).

Use the first if you want to download a .deb to then tinker with it (uncompress it, poke at it with dpkg, whatever).

Use the second if you want to "pre-download" a set of packages for later installation.

roadmr
  • 34,222
  • 9
  • 81
  • 93