Leave only 3 latest kernels:
## dnf repoquery set negative --latest-limit ## ## as how many old kernels you want keep ## dnf remove $(dnf repoquery --installonly --latest-limit=-3 -q)