Linux Saving Disk Space Tips

Quick cleaning tips

Downloaded packages:

$ sudo aptitude clean
$ sudo apt-clean

Through this tool we can select only needed locale files:

$ sudo aptitude install localepurge && sudo localepurge

For my systems, the generated file has:

ocm@achtung:/var/log$ tail -10 /etc/locale.nopurge
#####################################################
# Following locales won't be deleted from this system
# after package installations done with apt-get(8):
en_US
en_US.ISO-8859-15
en_US.UTF-8
es_ES
es_ES@euro
es_ES.UTF-8

Logs dealing:

$ cd /var/log && sudo rm -rf messages kern.log && sudo touch messages kern.log && sudo chown syslog:adm kern.log messages && sudo chmod 640 kern.log messages

And at least, orphaned packages:

sudo aptitude install deborphan gtkorphan && gksudo gtkorphan

OLD kernels removal tool:

ocm@achtung:/boot/grub$ dpkg -l | awk '/ii  linux-imag/ {print} '
ii  l**inux-image-2.6.38-13-generic**                 2.6.38-13.52                               Linux kernel image for version 2.6.38 on x86/x86_64
ii  **linux-image-3.0.0-13-generic**                  3.0.0-13.22                                Linux kernel image for version 3.0.0 on x86/x86_64
ii  linux-image-3.0.0-14-generic                  3.0.0-14.23                                Linux kernel image for version 3.0.0 on x86/x86_64
ii  linux-image-generic                           3.0.0.14.16                                Generic Linux kernel image

ocm@achtung:/boot/grub$ uname -a
Linux achtung 3.0.0-14-generic #23-Ubuntu SMP Mon Nov 21 20:34:47 UTC 2011 i686 i686 i386 GNU/Linux

Now we can choose the kernels which no longer needed:

ocm@achtung:/boot/grub$ sudo apt-get remove --purge linux-image-2.6.38-13-generic linux-image-3.0.0-13-generic
Leyendo listas de paquetes... Hecho
Creando árbol de dependencias
Leyendo la información de estado... Hecho
Los siguientes paquetes se ELIMINARÃN:
  linux-image-2.6.38-13-generic* linux-image-3.0.0-13-generic*
0 actualizados, 0 se instalarán, 2 para eliminar y 1 no actualizados.
Se liberarán **231 MB** después de esta operación.
continuar [S/n]? s

And "manual" compressing ant removing old backups:

ocm@achtung:/boot/grub$ sudo find / -type f -size +100000 -exec ls -lh {} \; 2>/dev/null
-r-------- 1 ocm ocm 65M 2012-01-16 18:06 /run/shm/pulse-shm-1955389207

As an example, we can remove pulseaudio old swap memory files:

root@achtung:~# pulseaudio --cleanup-shm