• 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

Downlaod Ubuntu 26.10 Stonking Stingray

How To Shutdown Linux With A 15 Minute Delay And Message

Using Linux Terminal How To Get Total Disk Size In GB

Count And Find Number Of Files In A Linux Directory Using Command

Check How Many Users Are Created In Linux Ubuntu

How To Check User Permissions In Linux Using Command

Check Which Folder Is Taking More Space In Ubuntu Linux

How to Install Claude Desktop App in Ubuntu Linux

Job Scheduling Using At Command In Linux With Examples

How To Check Permissions Of A Directory In Linux Command

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

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