Skip to content
Fork of Ubuntu's purge-old-kernels, without the need for byobu. With a few minor changes in the notes.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Fork of Ubuntu's 'purge-old-kernels' (part of the byobu package), with a few minor changes in the notes. It's a shell script, meant for Ubuntu and its derivatives like Linux Mint.

Main reason for its existence: 'purge-old-kernels' has been deprecated since Ubuntu 16.04, because 'apt autoremove' should do the same job.

But 'apt autoremove' (apt-get autoremove) does much more than just deleting old kernels. This might be undesirable, which is why some may prefer this precision instrument for removing only old kernels.

Finally, this script is entirely independent from the byobu package, which is an additional advantage: you don't have to install any superfluous software.

This script will always keep the currently running kernel and its headers, which should make it safe to use.
The default is 2, which means that it keeps one spare kernel besides the currently running kernel.

Before you can use it, you need to make this shell script executable. See the usage instruction below.


  1. Launch a terminal window.
  2. Move the script from the folder Downloads to the folder /opt, with this command line (use copy/paste to transfer it):
    sudo mv -v ~/Downloads/ /opt
  3. Set the permissions right (also making it executable), with the following command (use copy/paste to transfer it):
    sudo chmod -v 755 /opt/
  4. Launch it with the command below (use copy/paste to transfer it):
    sudo sh /opt/

You can change the number of kept kernels with '--keep N'. For example: sudo sh --keep 3
You can’t perform that action at this time.