Monday, September 24, 2012

How to remove all repositories using zypper

If you need to remove all repositories, use this command:

zypper repos | grep Yes | cut -f3 -d '|' | sed -e "s/ //" | awk '{print "zypper rr " $1}' | bash

I would suggest first to try to see the output of the command without the last bash:

zypper repos | grep Yes | cut -f3 -d '|' | sed -e "s/ //" | awk '{print "zypper rr " $1}'


  1. This was helpful, thanks. Not sure why there isn't a zypper option to do this already.

    1. Sure, I am glad it was useful for you

  2. This comment has been removed by the author.

  3. In SLES 15, the addon repositories you select during installation will be automatically added to the OS repository list. I wanted to remove these repositories all at once, but looks like the Aliases contain spaces. So this neat command fails. I was unable to put quotes around the awk output. So here is what I came up with:

    for i in $(seq $(($(zypper lr | wc -l)-4))); do zypper rr 1; done