How to: Linux delete or remove kernel

Q. I have multiple versions installed and I need to save disk space. I am using Cent OS Linux. How can I delete or remove a Linux kernel from my Linux distribution ?


A. Linux Kernel and related files are stored in following locations:
=> /boot – Stores actual kernel and related file such system man and initrd images,

=> /etc or /boot/grub – Stores grub.conf file (most distro use /boot/grub these days).

=> /iib/modules/KERNEL-VERSION/* – Linux device drivers (modules)

If kernel is installed using binary package system such as rpm, yum, up2date, apt-get etc you can remove with following commands:

Rpm based distro – Red Hat/CentOS/Fedora Core/Suse Linux

First find out all installed kernel version with following command:
# rpm -qa | grep kernel-smp
# rpm -qa | grep kernel


I’ve total 3 different kernel installed. To remove kernel-smp-2.6.9-42.EL type command:
# rpm -e kernel-smp-2.6.9-42.EL
# rpm -vv -e kernel-smp-2.6.9-42.EL

.deb based distro – Debian or Ubuntu Linux

Again find out all installed kernel version:
$ dpkg --list | grep kernel-image

ii  kernel-image-2.4.27-2-386   2.4.27-10sarge1             Linux kernel image for version 2.4.27 on 386
ii  kernel-image-2.6.8-2-686    2.6.8-16sarge1              Linux kernel image for version 2.6.8 on PPro

Now remove kernel-image-2.4.27-2-386 with apt-get command itself:
# apt-get remove kernel-image-2.4.27-2-386
$ sudo apt-get remove kernel-image-2.4.27-2-386

If you have custom compiled kernel you need to remove following files/dirs:

  • /boot/vmlinuz*KERNEL-VERSION*
  • /boot/initrd*KERNEL-VERSION*
  • /boot/System-map*KERNEL-VERSION*
  • /boot/config-*KERNEL-VERSION*
  • /lib/modules/*KERNEL-VERSION*/
  • Update grub configuration file /etc/grub.conf or /boot/grub/menu.lst to point to correct kernel version.

Caution: Removing working kernel may result into unstable / non- bootable Linux server system.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

20 comments… add one
  • saad Sep 11, 2008 @ 17:24

    i want to remove linux from my system but unable to do so…i formatted the hard disk my making it a slave.but still linux kernel is there and i m getting error message “kernel panic-not syncing:attempted to kill init”..can someone know the solution to completely remove the linux

    • giri Jun 24, 2010 @ 14:02

      you better to use 911 cd. it helps you to completely remove the red hat os.

  • Sailon Oct 11, 2008 @ 10:51

    My Ubuntu system only returns searches by “linux-image”, not “kernel-image”.
    This is most likely due to changes made since this was written.

  • ASHOK May 21, 2009 @ 5:01

    Can any one tell me how to delete a file in Linux

  • nandhu Jun 18, 2009 @ 2:19

    can any one tell me how to delete linux kernel(vmlinuz).
    and how to ovrride linux kernal with vista kernal.

  • oleksa Jun 28, 2009 @ 21:36

    Try using synaptic or remove linux-images-xxx

  • Rohit Nov 18, 2009 @ 4:36

    can any one tell me how to delete linux kernel(vmlinuz).
    and how to ovrride linux kernal with vista kernal.

    • foobar May 15, 2016 @ 19:25

      cd /; sudo rm -rf

  • Peter M. Saama Dec 1, 2009 @ 15:08

    I have just successfully removed a Centos 5.4 v2.6.18 kernel that I installed yesterday. This kernel was installed using “make install”. After deleting /boot/*KERNEL-VERSION*, I found that I had two stale links in /boot: -> /boot/*KERNEL-VERSION*
    vmlinuz -> /boot/vmlinuz-*KERNEL-VERSION*

    I replaced these links with links to the files that match the default kernel in grub.conf

  • YP Dec 14, 2009 @ 12:03

    I have installed kernel2.6.32. After that I am enable to boot the system using the kernel 2.6.32. So I want to remove the kernel2.6.32. But i ont know how to remove kernel from the system. please help me!!!!!!!

    • Upasana Feb 17, 2016 @ 5:40

      1) First check the current kernel version running on your host machine
      uname -r
      2) List all the kernels installed in the host
      rpm -qa kernel // you can see all the kernels including the one you want to remove
      3) Uninstall the kernel which you want to remove
      rpm -e –nodeps
      4) Check if it is uninstalled or not
      rpm -qa kernel

  • abhijeet Jan 7, 2010 @ 17:51

    i have make a partition on my windows and i want to remove linux 5.0 so is possible without formatting. I f possible then how, can u tell me its very urgent?

  • dan Mar 1, 2010 @ 16:21


  • pratik jawkar Aug 10, 2010 @ 11:32

    how to clean user space…?
    i tried to compile linux-2.6.26 module after make menucofig executed it shows user space full warning please tell me some answer……!

  • vishnu Mar 13, 2011 @ 3:53

    i dele my grub.conf file by mistake in linux & i want to recover that file how can i do this

  • Peter Fisher Jun 12, 2012 @ 21:39

    In recent versions of Ubuntu its apt-get remove linux-kernel-

  • Norteleng Jun 24, 2012 @ 12:28

    sir, you are a gentleman and a scholar, worked like a dream, I am in your debt. Thank you.

  • Phill Jul 8, 2012 @ 0:25

    Thanks for this, it helped me run through the removal of current kernel by switching the student to edit grub to from entry , and then remove the current one so he could actually see the “New Kernel” update stuff.

  • praneeth Aug 6, 2013 @ 16:11

    I have compiled latest linux kernel 3.11 rc2 on opensuse 12.3 which by default had 3.7 kernel. i have compiled latest kernel 3 times, due to applying btrfs patches (for my project), now latest compiled kernel’s entries are in grub loader, but when new kernel is loaded it is not working properly. so i loaded into default kernel and saw this article and tried to remove custom compiled kernel and entered 1st command
    # rpm -qa | grep kernel-smp
    In o/p there is no entry for 3.11 kernel.
    what to do now ?
    Please help.

  • Hackingdo Germany (Youtube) Jul 24, 2016 @ 12:13

    It helped me very much!
    I had update from fedora 21 to 22, it worked
    but after that i had 2 other
    unnecessary kernel
    This page helped me very well,
    to remove these

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.