package-cleanup --oldkernels --count=1
dnf remove $(dnf repoquery --installonly --latest-limit=-1 -q)
or
dnf remove --oldinstallonly --setop installonly_limit=2 kernel
warning: Signature not supported. Hash algorithm SHA1 not available.
RedHat has disable SHA1 support for signing rpms, so if you want to install do the following before (and dont forget after):
update-crypto-policies --set DEFAULT:SHA1
dnf install oldapp.rpm
update-crypto-policies --set DEFAULT
Info: https://www.redhat.com/en/blog/rhel-security-sha-1-package-signatures-distrusted-rhel-9