Removing unneeded dependencies

Hello all, I’m using OpenSUSE 13.1. When I install a package, some other packages (dependencies) are installed together. BUT I noticed that if I remove this same package, sometimes a few packages are removed, that is, some unneeded dependencies are left behind. An hypothetical example to make it clearer: if I install a package X using zypper, it says I’ll have to install 10 packages in order to perform this action. I accept and it installs 10 packages. But then I ask zypper to remove package X, it says I’ll have to uninstall 8 (or less) packages. This makes me conclude that I might have unneeded dependencies wasting resources in my system. How do I identify these unneeded packages to get rid of them?

TL;DR: I need a zypper command equivalent to apt-get autoremove

See “zypper help rm”:

-u, --clean-deps            Automatically remove unneeded dependencies.

You can set this option in /etc/zypp/zypp.conf as well:

#### EXPERTS ONLY: Cleanup when deleting packages. Whether the solver should
## per default try to remove packages exclusively required by the ones he's
## asked to delete.
##
## This option should be used on a case by case basis, enabled via
## command line options or switches the applications offer. Changing
## the global default on a system where unattended actions are performed,
## may easily damage your system.
##
## CHANGING THE DEFAULT IS NOT RECOMMENDED.
##
## Valid values:  boolean
## Default value: false
##
# solver.cleandepsOnRemove = false

Or enable the option “Cleanup when deleting packages” in YaST.

http://wstaw.org/m/2014/04/27/yast2-000.png

Hi wolfi323, thanks for your reply. By using -u argument, I must specify a target package, right? But what about all previous packages I already removed? How do I find my current unneeded dependencies to get rid of them, without specifying a target (since there might be a lot of targets, and I can’t list them all)?

Correct.

But what about all previous packages I already removed? How do I find my current unneeded dependencies to get rid of them, without specifying a target (since there might be a lot of targets, and I can’t list them all)?

I don’t think there’s an easy way yet to do that with zypper.
But there are some filter options in YaST->Software Management->View Package Groups:
Recommended packages, suggested packages, orphaned packages (not available in any repo), unneeded packages (not required by any other packages).
Hint: to uninstall all packages in the list, just right-click on the package list and select “All in this list”->“Uninstall”.

Or you could use “rpmorphan”:
http://rpmorphan.sourceforge.net/
A package is included in openSUSE, you just have to install it with YaST or zypper.

I’m afraid my YaST -> Software Manager is slightly different than yours and it doesn’t seem to have the “orphan” group:

http://s3.postimg.org/jvab155k3/Screenshot_from_2014_04_27_19_05_41.png

I’ll check rpmorphan later to see if it can get rid of my uneeded dependencies.

You seem to be using the Gtk version.
That one is apparently missing that filter unfortunately.

I’ll check rpmorphan later to see if it can get rid of my uneeded dependencies.

It should.
And it has many more options. F.e. it can even uninstall applications that you didn’t start since a certain amount of time AFAIK.