Hosting or Servers Logo

How to Remove Orphaned Packages in Centos Linux

Keeping your Linux operating system organized and decluttered not only helps lower disk space but can speed up future updates or upgrades and provides less places for malware and viruses to hide.

In your favorite terminal, log on to your server and enter the following command.

dnf repoquery ------unneeded

This gives you a list of packages that DNF regards as no longer being needed by other installed packages. Of course, this may not mean it would be sensible to remove them, but it gives you a starting point for your investigations.


The following command will also show you a list of packages that are not dependencies and that DNF can remove using the autoremove command.

dnf list autoremove

DNF list autoremove

In the above example DNF says we can remove grub2-tools and libssh2 without breaking other packages.


Now enter the following command to automatically remove the packages that DNF thinks are orphaned.

dnf autoremove

DNF autoremove

It should be remembered that if you have installed packages independent of DNF then they may be dependent on the packages that autoremove claims it can safely remove. This command is powerful and has the potential to break your operating system if not used with care.

You Are Leaving Us

This link is being provided as a convenience and for informational purposes only it is not an endorsement or an approval of any of the products, services or opinions of the corporation or organization or individual.

Hostingorservers.com bears no responsibility for the accuracy, legality or content of the external site or for that of subsequent links.