How do I free up disk space?

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) (google translated)


  • show top 10 biggest subdirs in the current dir.

    du -sk * | sort -nr | head -10
    
  • use filelight or kDirStat to see where the disk space is going visually

  • check if you have old kernels for deletion

    ls -lh /boot
    
  • cleaning packages

    sudo apt-get autoremove
    sudo apt-get autoclean
    

    see list of all installed packages, sorted by size. If you see something big and don't use it - uninstall it

    dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | less
    
  • clean unused language files with translations (there are tons of them)

    sudo apt-get install localepurge
    
  • check content of /var/tmp/

    du -sh /var/tmp/
    
  • check also

    man deborphan
    
  • Search for big files:

    find / -type f -size +1024k
    

    or

    find / -size +50000  -exec ls -lahg {} \;
    
  • big installed packages

    dpigs
    

this is part of the package: debian-goodies


sudo apt-get autoremove

That can clean out a lot of guff (old kernels, etc) that have been replaced. You can do a similar thing in Synaptic (load it up and select the status button and then the Auto-removeable option).

Tags:

Server