Some simple ways to free up space on Ubuntu
apt-get autoremove
Check the amount of apt-cache on your system
du -sh /var/cache/apt
Remove all apt-cache from your system
apt-get clean
Remove specific packages
apt-get remove package-1 package-2
Remove packages and dependencies that are no longer required
apt-get autoremove
List your current version of linux kernel
umame -sr
Check how many linux kernels versions are installed
dpkg -l | grep linux-image | awk '{print$2}' | wc -l
Check which linux kernels versions are installed
dpkg -l | grep linux-image | awk '{print$2}'
Find the linux image number and set the LINUXIMAGE
, for example linux-image-3.13.0
LINUXIMAGE=linux-image-3.13.0
Find the linux image extra number and set the LINUXIMAGEEXTRA
, for example linux-image-extra-3.13.0
LINUXIMAGEEXTRA=linux-image-extra-3.13.0
Find the lowest version number and set the STARTNUM
, for example 50
STARTNUM=50
Find the version number before the current version and set the ENDNUM
, for example 100
ENDNUM=100
Automagically delete all the old kernel versions
for i in $(seq $STARTNUM $ENDNUM); do apt remove --purge $LINUXIMAGE-$i-generic -y; done
for i in $(seq $STARTNUM $ENDNUM); do apt remove --purge $LINUXIMAGEEXTRA-$i-generic -y; done
Greetings.
There is a typo in the section "Remove Old Kernels". The first command should read
uname -sr
.