Removing old kernels

RHEL/CentOS/Oracle 8

To remove all but the last 2 kernels you can run:
# dnf remove --oldinstallonly --setopt installonly_limit=2 kernel

This is a handy reference page has much more detail on managing older kernels that may be causing positives on your vulnerability scans:
https://www.golinuxcloud.com/remove-old-kernels-rhel-centos-8/