I used this command
echo $(dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p') $(dpkg --list | grep linux-headers | awk '{ print $2 }' | sort -V | sed -n '/'"$(uname -r | sed "s/\([0-9.-]*\)-\([^0-9]\+\)/\1/")"'/q;p') | xargs sudo apt-get -y purge
from this link to remove old kernels to free up the disk space, but while executing that command I get the following message
...
1 upgraded, 2 newly installed, 2 to remove and 288 not upgraded.
Need to get 52.0 MB of archives.
After this operation, 186 kB of additional disk space will be used.
...
Shouldn't this command free up the disk space instead of using additional disk space ?
sudo apt autoremove
– Aaron Franke Dec 05 '16 at 21:48