36

As time goes by we tend to do apt-get install and add or replace software.

Are these archived in some form or do they get auto-cleared after installation? And if it doesn't get auto-cleared, it would mean that a clean up is needed, isn't it?

Finally, if they're not auto-removed, can we reuse these packages on different machines?

Seth
  • 58,122
itsols
  • 1,140

1 Answers1

48

The downloaded packages are stored in /var/cache/apt/archives

If you want to remove them, use sudo apt-get clean.

From man apt-get:

clean

clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. When APT is used as a dselect(1) method, clean is run automatically. Those who do not use dselect will likely want to run apt-get clean from time to time to free up disk space.

autoclean

Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control. The configuration option APT::Clean-Installed will prevent installed packages from being erased if it is set to off.

Sergey
  • 43,665
  • 1
    @Sergy thanks for that input. One more thing - can I copy the downloaded files and just rerun them on another computer? thanks again! – itsols Aug 22 '12 at 03:46
  • Yes, I never tried that but I think that just copying the files to /var/cache/apt/archives on another machine would allow you to install them without re-downloading (it would be better if they run the same distribution, of course). Alternatively, you can set up an NFS share from where all machines will install updates – Sergey Aug 22 '12 at 03:56
  • "The difference is that it only removes package files that can no longer be downloaded, and are largely useless" Interesting! I would have thought it was the ones that can no longer be downloaded that you might like to keep. :) – Jazz Aug 22 '12 at 04:06
  • Yep, this is a bit confusing, but they're actually talking about old versions of software. After foo-1.0.2 is released, foo-1.0.1 is removed from the servers because nobody needs it anymore, when you type sudo apt-get install foo it'll download and install 1.0.2 even if 1.0.1 is in the cache. So, once it's removed from the servers, it is unlikely you'll ever need it – Sergey Aug 22 '12 at 04:14
  • You can need it if the new one is broken, and you can force the install of a certain version (if it's still present on the server). Anyway debian has a website with all the versions of every package. – LtWorf Feb 04 '16 at 16:01
  • late to the party. But @LtWorf. Anyway debian has a website with all the versions of every package. could you share the URL. – samshers Aug 26 '20 at 16:18
  • @samshers: I think for Ubuntu it's https://packages.ubuntu.com/ – Sergey Aug 27 '20 at 01:02
  • @samshers https://snapshot.debian.org/ – LtWorf Aug 27 '20 at 22:37
  • @Sergey that doesn't have all the versions at all -_- – LtWorf Aug 27 '20 at 22:40