Author Topic: How to clean up diskspace (get disk space back) by cleaning yum / apt cache  (Read 644 times)

0 Members and 1 Guest are viewing this topic.

Offline hostmaster

  • Administrator
  • Newbie
  • *****
  • Posts: 20
  • Karma: +1/-0
    • View Profile
Your program repositories on CentOS (and other Red Hat / RPM-based systems) as well ass Debian, Ubuntu (and other systems that uses the apt-programs for management of installed programs) use cache.

This local cache can easily grow HUGE.

It is a good idea to clean this space up. If you are running out of diskspace - try this first and before ordering more diskspace (maybe you dont really need more space but only need to remove unused files).

1. The YUM way:
On systems running CentOS, Fedora, Red Hat and similar you can install the package yum-utils (yum install yum-utils) and then run:

yum clean all

You can also run package-cleanup --leaves --all

check the man pages and help texts for more information about these programs. On a typical webserver type installation that has been running a while you could easily clear up a couple of gigs by running this. Try it, it only removes stuff you dont really need anyway!

2. The APT way:

On Debian, Ubuntu and similar systems you can use a similar program;

apt-get autoclean

Also check the manpage and see if the purge alternative maybe be useful for you.

To see how much diskspace you have you run df -h ("h" means "human readable, ie a more user friendly way of presenting disk usage by the program df). If you still need to free more diskspace - use the df-program and see which files and directories take up the most space. Use bz2 (bzip2) to compress files and see the man page for bzip to see how to tweak and compress the files the most on your system - this will save a lot of space. Old logfiles is an example of files that typically grow large but can be decreased SIGNIFICALLY (!) by simply compressing them.