One would think that Ubuntu would be smart enough to remove obsolete kernel packages by itself. One would be wrong.
I think the Computer Janitor can clean them up but you still have to run that manually. So I prefer the following command:
uname -r; sudo apt-get remove $(dpkg --get-selections 'linux-image-*' | grep '\binstall' | head -n-3 | cut -f1)
This removes all kernels except the latest two. It prints the currently running kernel version so you can easily check that it's not removing that one.