Safely Remove / Delete Old Linux Kernel from a Linux Server

We have four different versions of Linux kernel installed by the yum command under CentOS Linux. Currently, I am using only latest version 2.6.18-53.1.4.el5. What is proper and suggested method to remove old kernels from a CemtOS / Debian Linux server?

Most Linux distro keeps old kernel files so that you can revert in case of emergency pop up due to hardware or software incompatibility issues. A kernel is nothing but a set of files on Linux box. Following is the suggested way to remove old kernels safely on Linux based system.

Step # 1: Find the current kernel version

uname -r
Sample outputs:


Step #2: List all installed kernels

Use the rpm command or dpkg command on Linux:
# rpm -q kernel
Sample outputs (from RPM based distro such as CentOS/RHEL):


Debian / Ubuntu Linux user, enter:
$ dpkg --list 'linux-image*'
Sample outputs:

| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name                          Version                       Description
ii  linux-image                           Generic Linux kernel image.
un  linux-image-2.6                                       (no description available)
rc  linux-image-2.6.20-15-generic 2.6.20-15.27                  Linux kernel image for version 2.6.20 on x86/x86_64
ii  linux-image-2.6.20-16-generic 2.6.20-16.32                  Linux kernel image for version 2.6.20 on x86/x86_64
ii  linux-image-2.6.22-14-generic 2.6.22-14.47                  Linux kernel image for version 2.6.22 on x86/x86_64
ii  linux-image-generic                   Generic Linux kernel image

Step #3: Remove all old kernels

WARNING! These examples may result into unstable system if not executed with care. Do not remove the kernel the system is currently running.

Choose which kernel you want to uninstall from the list of those installed. Type the following command to remove the kernel package under RHEL / CentOS / Fedora Linux:
# rpm -e kernel-2.6.12-1.el5
Type the following command to remove the kernel package under Debian / Ubuntu Linux:
$ sudo apt-get remove linux-image-2.6.22-14-generic
Please note that on newer system all obsolete kernels and headers should automatically be flagged as no more needed, and thus can be purged with the following single command:
$ sudo apt-get --purge autoremove
Sample outputs:

Fig.01: Deleting all older kernels on an Ubuntu server

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts