How to remove all unused old kernels on Ubuntu 20.04 LTS server

My /boot/ is running out of disk space and I see 8 different versions of Ubuntu Linux 20.04 LTS kernel. Is there is anyway to remove all unused old kernels on Ubuntu 20.04 LTS server safely? What command I need to punch in to delete old kernels from Ubuntu version 20.04? Please advice.

Ubuntu only keeps the last three kernels. But for some reasons, if you have more than three Linux kernel, try the following procedure. And yes, it is a safe procedure.

Removing all unused old Linux kernels on Ubuntu 20.04 LTS server or desktop

  1. As always, keep backup all data.
  2. Get the current disk space usage by running the df -H command.
  3. Open the terminal and then type any one of the following command to delete old Linux kernels on Ubuntu 20.04 LTS system:
    sudo apt --purge autoremove
    OR
    sudo apt-get --purge autoremove
  4. Veriy disk space by typing the df -H command.

See:


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