Skip to content

Instantly share code, notes, and snippets.

@yannvery
Last active May 19, 2022 09:44
Show Gist options
  • Save yannvery/93c007154901341867f8 to your computer and use it in GitHub Desktop.
Save yannvery/93c007154901341867f8 to your computer and use it in GitHub Desktop.
Ubuntu - Purge old kernels and unused modules

Ubuntu - Purge old kernels and unused modules

Purge old kernels

Open terminal and check your current kernel:

uname -r

DO NOT REMOVE THIS KERNEL!

Then, type the command below to list all installed kernels on your system.

dpkg --list | grep 3.16.

Find all the kernels that lower than your current kernel. When you know which kernel to remove, continue below to remove it. Run the commands below to remove the kernel you selected.

sudo apt-get purge 3.16.X-X-generic 

Remove temp installation files

Open a terminal.

Remove outdated packages from cache:

sudo apt-get autoclean

Remove every package from the cache:

sudo apt-get clean

Remove installed packages as dependencies which have been unused

sudo apt-get autoremove
@solbu
Copy link

solbu commented Mar 26, 2022

«apt-get autoclean» does not just delete outdated packages, it removes them from the cache, there is a difference.
May I suggest changing the description from «delete outdated packages» to «delete outdated packages from cache».

«clean» is a harder version of «autoclean»: it removes every package from the cache, not just those that can no longer be downloaded/installed (what you call «outdated» in this text).

@yannvery
Copy link
Author

@solbu thanks for the clarifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment