How to remove all packages with DNF on which no other package depends on
With Yum, you would use the package-cleanup
command from yum-utils
. But, with DNF, it's built in as the dnf autoremove
command. From the docs:
dnf [options] autoremove
Removes all “leaf” packages from the system that were originally installed as dependencies of user-installed packages but which are no longer required by any such package.
Note that you can also use the dnf list
command to see which packages would be removed, before running the automremove itself, with
dnf list autoremove
Also note that DNF has another difference in behavior which should help you out in similar situations (but not your exact case). If your main piece of software were installed by DNF (rather than outside of DNF by hand), and you used dnf remove
, the default (unlike yum) is to also remove any dependencies which were added just for that package and which aren't used for anything else.