11

I used to use yum to list all installed packages:

yum list installed

Now I need to list top level packages only i.e. if a package is a dependency of another, it should not be shown. GNOME's Add/Remove Software can do this but I need the output in a terminal.

I checked yum manual but I could not find a switch for that.

3 Answers 3

13

You can use the tool package-cleanup which is part of yum-utils. Besides finding packages which are not available from the current yum repositories, finding packages with broken dependencies, pruning old kernels and finding duplicate packages it can also find packages on which no other packages depend. Those are called leaves. Do

yum install yum-utils

to get package-cleanup and

package-cleanup --leaves --all

to get a list of all leaves.

2
  • The Debian/Ubuntu terminology for this is orphans.
    – tshepang
    Feb 24, 2011 at 22:05
  • 2
    @Tshepang, this is not correct - not all leaves are unused. And not all orphan packages are necessarily leaves. Orphan packages in Debian terminology means: previously as dependency (including transitive dependencies) installed packages that are now unneeded because the explicitly named installed packages are now removed. Jul 13, 2013 at 16:14
3

You can use the command repoquery (part of the package yum-utils) to get this information:

$ repoquery --installed --qf '%{n} - %{yumdb_info.reason}' --all \
    | grep 'user$' | cut -f1 -d' '

It only lists packages you have installed on your own - not those which are part of the base install. Depending on your use case this is what you want or not.

1
  • This one looks very useful. Thanks! Importantly, the packages are listed without versions and .i686 or .noarch or whatever so no sedding or modification needed before yum install -y.
    – gaoithe
    May 1, 2015 at 10:01
0

You could try dnf history userinstalled which is designed for this purpose. However, it's possible for it to get a bit confused, as this discussion shows.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .