Zypper Equivalent for apt-get autoremove

Debian has the following command: apt-get autoremove

This is used to remove packages that were automatically installed to
satisfy dependencies for some package and that are no more needed.

Just curious to know if there is a zypper equivalent.

Thanks.

tb

the switch --clean-deps
for example

zypper rm chromium --clean-deps

removes chromium and the dependencies that wore installed.

if you want to remove orphaned packages (packages that wore pulled by a now uninstalled app) try

zypper packages --orphaned

that will command will print a list of orphaned packages that you can safely remove

Hello,

In far the majority of the cases, part of the question/problem description is what versions of what software is used. Particulary which version of openSUSE.

Because many people seem to forget this, in the web interface of these forums we force our users by a menu to choose a version that then is displayed as a prefix to the thread title.

You apparently use the NNTP interface where we can not enforce such a thing. So please try to remember this basic fact next time you start a thread and mention the openSUSE version your thread is relevant to.

On 09/12/2016 08:36 AM, hcvv wrote:
>
> tb75252;2792153 Wrote:
>> Debian has the following command: apt-get autoremove
>>
>> This is used to remove packages that were automatically installed to
>> satisfy dependencies for some package and that are no more needed.
>>
>> Just curious to know if there is a zypper equivalent.
>>
>> Thanks.
>> –
>> tb
> Hello,
>
> In far the majority of the cases, part of the question/problem
> description is what versions of what software is used. Particulary which
> version of openSUSE.
>
> Because many people seem to forget this, in the web interface of these
> forums we force our users by a menu to choose a version that then is
> displayed as a prefix to the thread title.
>
> You apparently use the NNTP interface where we can not enforce such a
> thing. So please try to remember this basic fact next time you start a
> thread and mention the openSUSE version your thread is relevant to.
>
>

Sorry about that! I am using openSUSE Leap 42.1, 64-bit.

tb

I haven’t used ubuntu in a long time and then it was for a few days
but isn’t

zypper rm <package name> --clean-deps

what you wanted?

I think that should be:

zypper rm --clean-deps <package name>

(options go first).

But I think the OP wanted to remove left-overs without specifying a particular package.

You can do that in Yast. Select the “Package Group” view, and then click on “Unneeded packages” for a list of them. Those should be safely removable, since they are unneeded.

I think that’s a bug from the manual
http://doc.opensuse.org/documentation/leap/reference/html/book.opensuse.reference/cha.sw_cl.html#sec.zypper.softman

If (together with a certain package) you automatically want to remove any    packages that become unneeded after removing the specified package, use    the --clean-deps option:   
zypper rm *package_name* --clean-deps

I am always confused with such an option. What is “unneeded”? What is the technical definition of “unneeded” in this case? I can imagine that it is a package that is not a dependancy of any other package. But that would mean that a package at the top of the dependancy list like Amarok is “unneeded”, because it is not needed by another package. That it IS needed by the user is not something the system can know (as long as it is not a mind reading system).

And as long as I do not understand what it realy means, I am reluctant to use any action based on it. :wink:

Somewhere above orphaned packages are mentioned. Again a definition of what that is is needed to understand what doing actions on them will bring about. IMHO orphaned packages are packages that are not in any repos the system is subsribed to. Thus they can either be from direct RPM installations (not from a repo), or from repos that are disabled/removed. They are shown red in the YaST listings. Can any body confirm this or give the correct definition.

I’m not sure, either. But I’m guessing that it is a package that is neither a dependency nor a recommend. And maybe it can’t be a pattern either.

Actually this is not correct. --orphaned means packages that do not come from a repo. For instance I
install the Atom IDE directly from a RPM, so it shows up as orphaned.

What I believe you are looking for is:

zypper packages --unneeded

It just shows the list of packages. But

apt-get autoremove

removes them. How to remove them automatically?

P.S. Found some helpful info here: https://forums.opensuse.org/showthread.php/497541-Removing-unneeded-dependencies?p=2639663#post2639663
and here: https://github.com/openSUSE/zypper/issues/116

According to the zypper MAN pages,

As you described, the following only displays remaining unneeded dependencies after a package has been removed

zypper se --unneeded

and, the following removes said unnecessary dependencies

(long form)

zypper rm --clean-deps

(short form)

zypper rm -u

Something nice to know, and to be tested.

TSU

This does not work without package name like autoremove works. See my links above with solution.

Am testing now. I simply specified the RegEx wildcard (*) for package name on one of my TW/KDE in a virtual machine (so that I have an easy way to snapshot and roll back during testing).

So, the following runs

zypper rm -u *

zypper is now removing over 3.5Gb of packages deemed currently “unnecessary.”

I’m wondering at the moment how this would affect BTRFS rollbacks.

It’ll be interesting if the result works, and the consequences.
Until those consequences are fully known, I’d recommend caution.

Read your links, for now don’t believe they are more informative, and they talk about the same commands i describe.

TSU

Not same, read the message:

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”.

Not equivalent, but workaround for now.

First result,
The command as I described breaks openSUSE, there are errors relating to grub and a reboot is to a MinimalX login that is not functional.

So,
Until further notice Do not remove unnecessary dependencies arbitrarily.

TSU

did a brief analysis of the packages deemed “unnecessary” using the following command, and… I can’t imagine why the listed packages make the list. All of the apps/packages seem to be desirable if not absolutely needed, and AFAIK no alternate packages with replacement functionality are installed.

So,
Without some kind of explanation why these “unnecessary” packages are recommended for removal, I would not suggest that any should be removed.

For now, I do know if there is any value to the command, and do not recommend removing any packages displayed
This appears to be the same as the “Unneeded” group in YaST Software Manager

zypper packages --unneeded

Bottom line,
Whether you use YaST or zypper, do not remove a package just because it appears in any of these lists… unneeded, orphaned, multiversion, etc.

TSU

zypper rm -u *

doesn’t that command remove every package you basically uninstalled everything
afaik zypper does not have an equivalent to apt-get automove cleandeps is good when removing packages that might have pulled a lot of dependencies and while zypper doesn’t do autoremove it’s dependency resolver is great
regarding unneeded software I’ve noticed a bug in 42.3 (I don’t know about TW) where a lot and I do mean a lot of packages get flagged as unneeded this included some nvidia driver packages (for me) this didn’t exist in 42.2 and older
I didn’t really see the need to open a bug report but as a caution:
Do not remove packages flagged as unneeded in yast (or zypper with zypper packages --unneede) as most of them are needed

Regarding the idea that these links provide some kind of workaround…

After a careful read,
IMO
The idea that Yast displays something different than and works differently than the corresponding zypper commands is not correct, at least today(Can’t know what the posters were seeing back in 2014). Yast and zypper display the exact same list of packages and operate on the list the same way.

The only thing in the referenced thread I didn’t check is the 3rd party app “rpmorphan.”
As of today, it looks like a currently maintained app but has mainly been developed to support yum and dfs in Fedora. It <may> work on openSUSE but I didn’t test.

TSU