Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just switched from Ubuntu to Fedora14. In Ubuntu we had the apt-get autoremove thing to remove orphan/unused packages. What is the counterpart in Fedora?

share|improve this question

migrated from stackoverflow.com Oct 26 '11 at 14:31

This question came from our site for professional and enthusiast programmers.

package-cleanup --quiet --leaves from the yum-utils package will list the library packages which aren't relied upon by other packages. Unfortunately it tends to be a bit overeager. On my system, for example, it suggested removing libvirt. Adding the --exclude-bin argument helps. If you're happy with it's suggestion, then to clean up the packages, do:

# package-cleanup --quiet --leaves --exclude-bin | xargs yum remove -y
share|improve this answer
Tested it after installing and removing netbeans-platform and package-cleanup lists some stuff but actually none of the previously installed netbeans-platform dependencies (using Fedora 17). – maxschlepzig Nov 17 '12 at 17:51
Doesn't work, as pointed by @maxschlepzig – c0da Feb 10 '13 at 4:05

DNF, the yum replacement since Fedora 22, also provides a autoremove subcommand which is modeled after apt-get/yum autoremove.


# dnf autoremove

which tries to remove all automatically installed and otherwise unused dependency packages - should be pretty much equivalent to apt-get autoremove.

# dnf autoremove examplepackage

which removes examplepackage and all its automatically installed (and otherwise unused) dependencies.


Yum has the autoremove command since Fedora 19, and it is documented since Fedora 20/RHEL 7.

The usage is analogous to the dnf implementation, e.g.:

# yum autoremove


# yum autoremove examplepackage

Change the behavior of yum removes

Yum supports a config option to change the default behavior of the remove subcommand (e.g. via /etc/yum.conf):



When this is set, the next yum remove also tries to remove auto installed dependencies iff they are not needed by other packages.

You can also temporarily test this option via something like:

# yum --setopt=clean_requirements_on_remove=1 remove examplepackage

Workaround for old Fedora version

(For Fedora versions where the yum autoremove subcommand is not available and/or clean_requirements_on_remove does not work.)

Although during installation of packages installed dependencies are marked as such (seems to be relatively new feature of rpm/yum).

You can find unneeded dependencies via:

$ package-cleanup --leaves -q --all \
    | xargs repoquery --installed --qf '%{nvra} - %{yumdb_info.reason}' \
    | grep -- '- dep' \
    | cut -d' ' -f1 > tmp

This command line is inspired by fenris02's script.

After inspection of tmp (and perhaps curation) you could remove them via something like this:

# xargs yum remove < tmp
share|improve this answer
It gave the error "Invalid yumdb querytag 'reason' for installed pkg: adobe-release-x86_64-1.0-1.noarch". What is this now? – c0da Feb 11 '13 at 9:39
@c0da, I guess that the feature that yum records in its database the 'reason' of installation (e.g.'dep' or 'user') for each package is relatively new. Perhaps your Fedora instance predates the introduction of that feature such that you have still (a few) old packages installed without that tag set. – maxschlepzig Feb 11 '13 at 21:10
I installed Fedora 18 a few days back. So I think the required tag should be there. – c0da Feb 12 '13 at 9:54
@c0da, perhaps the 'reason' was not recorded because you have installed the package adobe-release via yum localinstall – maxschlepzig Jul 13 '13 at 19:15

you need to install the yum plugin "remove-with-leaves":

# yum install yum-plugin-remove-with-leaves.noarch

once installed:

# yum remove --remove-leaves package

good luck!

share|improve this answer
and how to run it for all installed apps? – Cynede Mar 20 '12 at 11:20
Does not seem to be very reliable as well: skvidal.wordpress.com/2010/11/09/orphaned-dep-cleanup-in-yum – maxschlepzig Nov 17 '12 at 18:06
RHEL/CentOS/Oracle Linux 6 needs the yum-plugin-remove-with-leaves.noarch package installed to use package-cleanup – Terry Wang Jan 31 '13 at 3:55
Excellent answer. Love this tool. Please accept this answer the author deserves it. – Routh Jun 14 '15 at 15:14
# package-cleanup --orphans >/tmp/junk

edit the /tmp/junk file and remove the first line which is informational from the command line enter the following:

for file in `cat /tmp/junk`
  yum remove $file
share|improve this answer
package-cleanup(1) says: '--orphans List installed packages which are not available from currently configured repositories.' This is not equivalent to what apt-get autoremove does. apt-get(8) says: 'autoremove is used to remove packages that were automatically installed to satisfy dependencies for some package and that are no more needed.' – maxschlepzig Nov 17 '12 at 17:57
Doesn't work! I must have been mistaken previously. Thanks @maxschlepzig – c0da Feb 10 '13 at 4:05
This used to work for me but in CentOS 6.6 it actually lists all installed packages, not just orphans. – Gaia Jan 21 '15 at 18:51

NOTE: This answer is correct but only applies to RHEL 7+ and Fedora 20+ (where autoremove has been added as a new feature).

# yum autoremove

Just confirm to remove the selected packages.

share|improve this answer

Building upon Larry Mohr's answer:

package-cleanup --orphans | sed '1d' | sed '/^ * /d' | sed '/Loading mirror speeds from cached hostfile/d' | xargs sudo yum remove

(Includes skipping for fastest mirror, if you wonder.)

share|improve this answer

In Fedora, the orphan package means no candidate repos for it to update!

  1. If the orphan packages were generated by you disable yum.repos.d/some.conf.

    yum distro-sync
  2. Other orphan packages, the command may be dangerous.

    yum remove $(package-cleanup --orphans)

    or, just use the safety command.

    yum remove name-of-page
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.