Ubuntu Linux delete older kernel that is no longer needed

Is there is a command to delete older kernel in an Ubuntu Linux 18.04 server? I see so many kernel installed in my server at AWS EC2. How to tell Ubuntu Linux to delete older kernels?

The procedure to delete older kernel in Ubuntu is pretty simple:

  1. Login to your server
  2. Type sudo apt --purge autoremove to delete and purge all outdated and older Ubuntu Linux kernels.
  3. Reboot the server if new Ubuntu Linux kernel was installed by running sudo reboot
  4. Verify by running either df -H or sudo dpkg --list | egrep -i --color 'linux-image|linux-headers

For more info see my page

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki