Say I've added a repository using zypper ar. Then, I've gone and installed multiple packages from that repository, but now I want to remove all of them.

Is there a command that allows me to remove all the packages that I've installed just from that specific repository?

3 Answers 3


I think there is no such command. You can list packages from specific repository:

zypper search --installed-only --repo devel:tools

or all orphaned packages if you've already removed that repository:

zypper packages --orphaned

Then you could try to cut package names from the output and pass it to zypper remove if it's worth the effort.

  • My openSuSE 12.3 system does not have the --orphaned option, but this might work: zypper packages -i -R: it lists the installed package in Reverse order of repository. May 31, 2014 at 10:57
  • 2
    --orphaned was added in zypper 1.9.2 (github.com/openSUSE/zypper/issues/34)
    – marcin
    May 31, 2014 at 11:48

You can use a combination of zypper search, awk and xargs to remove all packages from a repository. For example:

zypper se --repo openSUSE-Tumbleweed-Debug --installed | awk '/^i(\+|\s)/ {print $3}' | xargs sudo zypper rm
  • awk '/^i(\+|\s)/ {print $3}' to match all installed packages (i or i+)
    – Mesco
    Apr 23, 2018 at 15:20
  • @Mesco zypper itself should only print installed packages when using --installed.
    – sebix
    Apr 24, 2018 at 13:44
  • right, using -i or --installed-only. But also I've search for i and i+ at the beggining to skip first few rows (Loading repository data...). Maybe there are better methods, to skip first 5 rows but if you already use regex... ;)
    – Mesco
    Apr 24, 2018 at 19:54
  • maybe I'm using different zypper version (1.14.4) but its man says that the order should be se [options] [query] so your solution didn't work.
    – Mesco
    Apr 24, 2018 at 19:59
  • Ah, now I understand your concern. I updated the answer. About the search-syntax: I only use options and no query, so the order is correct I think.
    – sebix
    Apr 26, 2018 at 10:03

This line works fine for me

zypper search --installed-only --repo yourbadrepo|awk {'print $3'}|xargs sudo zypper rm 

If you want to risk or use in a script, the -n option avoid confirm(can break deps)

  zypper search --installed-only --repo yourbadrepo|awk {'print $3'}|xargs sudo zypper -n rm 

You must log in to answer this question.

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