74

I think once we get the packages with apt-get it stores in /var/cache/apt/archives . Is it safe to remove the archives files to save space? Can we remove other files as well to save some space?

6 Answers 6

109

I think it's safe to remove the archives files. So if you want to free up disk space this are my recommendations:

To delete downloaded packages (.deb) already installed (and no longer needed)

sudo apt-get clean

To remove all stored archives in your cache for packages that can not be downloaded anymore (thus packages that are no longer in the repository or that have a newer version in the repository).

sudo apt-get autoclean

To remove unnecessary packages (After uninstalling an app there could be packages you don't need anymore).

sudo apt-get autoremove

To delete old kernel versions

sudo apt-get remove --purge linux-image-X.X.XX-XX-generic

If you don't know which kernel version to remove

dpkg --get-selections | grep linux-image

Source: Limpiando Ubuntu: comandos y programas (actualización) & How do I free up disk space?

3
  • 1
    Very nice, thanks! Curiously though, have you even had the need to go on to an older kernel version? I did a couple of times between 2005 and 2009 but not lately.
    – itsols
    Sep 19, 2013 at 3:48
  • I found apt-get --purge autoremove at cyberciti.biz/faq/… which you can use to remove old linux kernel images
    – Jelmer
    Oct 31, 2016 at 19:46
  • @itsols I have to revert a kernel a few days ago, a laptop would not boot with the new kernel. Jan 8, 2019 at 9:34
11

Yes, it is generally safe to remove them, unless you had a bad Internet connection and you needed to reinstall certain packages.

To remove them, open a terminal and type:

sudo apt-get clean

You can also use Ubuntu-tweak and Bleachbit.

6

And related at the clean cache... you can use this command

sudo dpkg --purge `COLUMNS=300 dpkg -l "*" | egrep "^rc" | cut -d\  -f3`

in order to delete all configuration related to unistalled program.

And:

1) localepurge: for delete localizazion packages not interested for you

2) deporphan and his gnome interface gtkorphan.

2
  • egrep appears to be deprecated nowadays; it can be replaced by "grep -E"
    – db-inf
    Oct 8, 2020 at 7:55
  • this worked for me
    – marbel
    Nov 27, 2020 at 14:04
0

You can run 'sudo apt-get clean' to clean out any cached .debs. If they're needed, they will be downloaded again. There's also a program called computer-janitor to help with removing old files.

1
  • 1
    Hum... the point here is setting a flag that disables .DEB caching one and for all... if that is really available, doing anything else (crons to delete old files, etc) sounds like reinventing the wheel to me. Feb 24, 2013 at 15:24
0

If you messed around with installing partial packages then "apt-get autoclean" removes them too.

I run a Cron job to do this on some systems backed up to the Cloud to keep file sizes down.

HTH,

JR

0

According to this : http://www.howtogeek.com/howto/28502/how-to-free-up-a-lot-of-disk-space-on-ubuntu-linux-by-deleting-cached-package-files/ there is an option to disable caching in synaptic package manager...

Does anyone know where is the configuration being defined? (no where in /etc/apt/ as far as I can tell)

2
  • 1
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Additionally please use the Post answer button only for actual answers, if you have a question, add it either as a comment to your answer or the original question.
    – Oyibo
    Feb 24, 2013 at 15:26
  • 1
    Sorry for that, but some how I missed the "add comment" link (have the feeling it was not there and I added an answer) until it was too late... be careful next time. Feb 25, 2013 at 11:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .