The problem is that the old kernels take place in boot folder and cause problems with installetion of new packeges and system upgrade.
Probably the easiest way is to use purge-old-kernels script.
1. First install it.
sudo apt install byobu
2. Then run the script regularly to remove old kernels
If there is already no free space in /boot folder, you cannot install new packages and have to clean up manually first.
Find you current kernel
And then remove some of the older ones from /boot folder using rm command.
Then you can install purge-old-kernels and run it.
After removing the old kernels you might need to run also
sudo apt-get -f install
Some sources recommend the following commands us useful alternatives.
sudo apt-get autoclean
This will eliminate any old files (Including kernel versions) you may have. Note that if you have many old versions, it will take a while since it has to make sure that removing the kernel version has no issues. For me, removing the last 12 kernel versions took about 2 minutes. You can also do the following:
sudo apt-get clean
Which will eliminate everything downloaded and stored in the cache folder of apt. Lastly you have:
sudo apt-get autoremove –purge
which would check for any unused packages and remove them if necessary. This is great for those libraries and dependency packages that are no longer needed byt any app installed.