• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / How To Remove Old Linux Kernels From Ubuntu Command Line

How To Remove Old Linux Kernels From Ubuntu Command Line

By Sourabh / July 24, 2023 Category: How To, Ubuntu

How to remove old Linux Kernels from Ubuntu? You can delete old Kernels via Ubuntu command line terminal or manually remove old Kernels.

Remove Old Unused Kernels in Linux

Before you remove old unused Kernels in Linux, you will need to check and verify all the installed Kernel. To do so, run the command “$ dpkg –list | grep linux-image”. This will show you the list of Kernels installed.

$ dpkg --list | grep linux-image

NOTE: In the list you will see column which displays “rc” and “ii”. They represent:

  • “ii” – “installed”. Kernels which are successfully installed on the system and is in a functional state.
  • “rc” – “removed”. These are removed Kernels but the configuration files are still present on the system. Which means Kernels which are removed but not purged completely.

Now, to remove and delete delete old and unused Linux Kernels, use the following command:

$ sudo apt-get autoremove --purge
$ sudo update-grub

NOTE: The “rc” packages are not removed when you execute the command “sudo apt autoremove –purge”. It is so because the “autoremove” works on the packages that were installed but are no longer needed.

If you wish to remove all “rc” packages, you can use the following command:

$ sudo dpkg --purge $(dpkg -l | awk '/^rc/{print $2}')

You can also remove a specific Kernel, using the following command:

$ sudo apt-get purge linux-image-x.x.x-x-generic

Where “x.x.x-x” represents the Kernel version. You can get the Kernel version using the command “$ dpkg –list | grep linux-image”.

NOTE: Command to keep only the currently running/active Linux Kernel and delete all other Kernels which are not used.

$ sudo apt-get purge $(for tag in "linux-image" "linux-headers"; do dpkg-query -W -f'${Package}\n' "$tag-[0-9]*.[0-9]*.[0-9]*" | sort -V | awk 'index($0,c){exit} //' c=$(uname -r | cut -d- -f1,2); done)

That’s all.

Primary Sidebar

Latest Posts

Clear History In Linux Terminal Permanently

How To Create Zip File In Ubuntu Terminal With Password

How To Check Difference Between Two Files In Linux Ubuntu

How To Check Kernel Installed Date In Linux Command Line

Ubuntu 25.04 ‘Plucky Puffin’ Is Available To Download

How to Login as Root User in Linux Terminal

Install Firefox In Ubuntu Terminal Command Line

How To List All Kernel Modules That Are Loaded In Ubuntu

Enable Ubuntu Auto Login Without Password

Download Ubuntu 25.04 Official Default Wallpapers

© 2025 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap