1

I wanted to do offline installation of some packages on an ubuntu machine which is not connected to internet. I have those packages on storage device. Can i use apt-get to install it

does apt-get checks cache directory before downloading packages?

  • Yes it does check it's cache before downloading it again. – Ziazis Jul 05 '17 at 12:53
  • Testing, it does seem to check the cache directory. A full set of answers is here: https://unix.stackexchange.com/questions/159094/how-to-install-a-deb-file-by-dpkg-i-or-by-apt – aplaice Jul 05 '17 at 12:57

2 Answers2

2

If you have the packages (.deb files), apt-get is not the best tool. Read man dpkg and use dpkg -i to install the .deb files.

waltinator
  • 36,399
1

In general, I'd recommend using dpkg -i, as waltinator wrote and it's the safe and sane method.

However, if you have a vary large number of packages, and you wish to easily manage installing and uninstalling them, with dependency management, the following should work:

sudo apt-get -o dir::cache::archives=/path/to/directory/containing/archives/ -o dir::state::lists=/path/to/directory/containing/lists --no-download install your-packages

In order for dependency management etc. to work properly, you may need to copy the package metadata (normally present at /var/lib/apt/lists/) to /path/to/directory/containing/lists on the offline computer.

You could also just copy the packages and the lists directly into the default directories /var/cache/apt/archives/ and /var/lib/apt/lists/, respectively, on the offline computer and skip the options part (-o dir::cache::archives=/path/to/directory/containing/archives/ -o dir::state::lists=/path/to/directory/containing/lists).

aplaice
  • 975