The APT package manager includes an auto-remove feature that can clean up unnecessary packages, including old kernels:
sudo apt autoremove --purge This command removes packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed, including old kernels. However, autoremove only removes kernels that were installed automatically . In case we install a kernel manually, this method might not remove it. Alternatively, we can also install byobu . It’s a command-line tool which can simplify the cleanup process: sudo apt-get install byobu After installation, let’s remove the old kernels: sudo purge-old-kernels The purge-old-kernels command keeps the current and previous kernel, removing all other old kernels.