16 August 2016

Linux: Free Up Disk Space

See where space is being used

  • Check the status of all disks:
    df -h
  • folders size: du --max-depth=1 -h /
  • sudo du -xm / | sort -rn

Ubuntu

On ubuntu you can free up space by clearing old app caches:

apt-get clean all
apt-get update
apt-get -f install
apt-get autoremove

Freeing up Disk Space

  • Delete log files in tmp
    cd /tmp/
    rm -rf *.log
  • Delete archived log files in tmp:
    rm -rf /var/log/*gz
    or to do this recursively:
    To see what it will delete:
    find . -name "*log*.gz" -type f
    find . -name "*log*.gz" -type f -delete

Log Rotate

Amend /etc/logrotate.conf e.g. using a guide like this one on thegeekstuff.com
e.g. reduce the amount you keep by

# keep 1 weeks worth of backlogs
rotate 1

No comments:

Post a Comment