Last Updated: February 25, 2016
·
1.48K
· daraff

Clean Up the Disk Space of your Ubuntu

Recently i was running out of space at my primary SSD hard drive.

I tried to cleanup unused stuff and i found some space wasters.

Old Linux Kernels

Here i found a very useful command to remove old kernels.

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

Remove unneeded modules

sudo apt-get autoremove

Remove Elasticsearch related data

curl "localhost:9200/_nodes/settings?pretty=true"

# Check settings.path.data f.e. /var/lib/elasticsearch
rm -rf /var/lib/elasticsearch/elasticsearch/nodes/0/indices/<unused-indices>

 # Remove elasticsearch log files
rm -rf /var/log/elasticsearch/*