Software >> OS >> Unix >> Linux >> RHEL >> How to remove older kernels from the system

## List the kernel versions installed

rpm -q kernel


## Ensure you have yum-utils package installed

yum install -y yum-utils


## Clean up

## For RHEL 7

## count is the number of kernel versions to leave behind. In the following example we keep 2 versions

package-cleanup --oldkernels --count=2



## For RHEL 8

dnf remove --oldinstallonly --setopt installonly_limit=2 kernel