Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
    
Now I have a PC that has Ubuntu. Can anybody verify the correctness of the below answers? –  c0da Nov 15 '11 at 11:55
    
the currently accepted answer by Larry Mohr is incorrect. –  maxschlepzig Nov 17 '12 at 17:59
    
Since this question was asked way back, right now I'm on Fedora 18. But the same problem is still there. –  c0da Feb 10 '13 at 4:26
    
have you tried the approach I described in my answer? –  maxschlepzig Feb 10 '13 at 22:29
add comment

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

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

7 Answers

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
    
Perfect, thank you –  Heather Sep 26 '12 at 11:01
    
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
add comment

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
2  
and how to run it for all installed apps? –  Heather 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
    
+1 Best answer so far –  cept0 Apr 23 '13 at 6:16
add comment
# 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`
do
  yum remove $file
done
share|improve this answer
1  
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
add comment

Currently, yum does not have a command that matches apt-get autoremove.

(Which is kind of surprising.)

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

Change the behavior of future yum removes

Yum now supports the config option (via /etc/yum.conf):

clean_requirements_on_remove=yes

yum.conf(5)

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

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
add comment
# yum autoremove
Loaded plugins: fastestmirror, langpacks, presto, refresh-packagekit, remove-
              : with-leaves
share|improve this answer
    
How does that relate to what is being asked? Remember that OP is familiar with Ubuntu, and needs guidance with Fedora. –  vonbrand Mar 3 '13 at 4:23
2  
@vonbrand Doesn't Fedora use yum? –  Michael Mrozek Mar 3 '13 at 5:20
    
wtf is that? yum autoremove Loaded plugins: fastestmirror, priorities No such command: autoremove. Please use /usr/bin/yum --help –  holms Dec 20 '13 at 20:28
add comment

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
add comment
yum remove $(package-cleanup --leaves)
share|improve this answer
5  
This is dangerous, as not all leaves are unused. –  mattdm Dec 28 '11 at 4:37
    
-1 This a very dangerous command !!! wtf –  cept0 Nov 20 '13 at 11:01
add comment

Your Answer

 
discard

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.