I want to force caching the installed packages with apt-get install (apt install) in /var/cache/apt. Currently, I found some of them are cached, but most of them are not. I want to cache all of them to install them on another machine by copying these packages without downloading them again from the Internet, especially for large packages which cost a lot of time.
Asked
Active
Viewed 901 times
0
Liang Xiao
- 123
- 1
- 7
-
2Possible: [How to create a local APT repository?](https://askubuntu.com/questions/170348/how-to-create-a-local-apt-repository) or [How can I install software or packages without Internet (offline)?](https://askubuntu.com/questions/974/how-can-i-install-software-or-packages-without-internet-offline) – Terrance Mar 25 '21 at 02:17
-
1The `apt` command doesn't cache the deb files by default, but the `apt-get` command does, so use `apt-get` and only `apt-get` if you want everything to be cached, or change the config as shown in https://askubuntu.com/a/794987/158442 – muru Mar 25 '21 at 10:37
1 Answers
1
I think that setting up your local machine as a repository would be a better option, but if you want to just download a package you can run:
sudo apt install -d package
If you want to cache all of your installed packages you can run
sudo apt install -d $(apt list --installed | cut -d'/' -f 1 | grep -v "Listing..." | tr '\n' ' ')
gabmus
- 100
- 1
- 9