Wednesday, January 30, 2013

openSUSE: zypper - the basics and beyond

When you start to use openSUSE, the first thing you discover is YaST. Amazing tool that it is -- and I really do recommend learning about it because it can be invaluable -- many package management tasks are better suited to the command line. And that means zypper.

Get to know it, because you'll be using it a LOT. I recommend the following reading list:

zypper reading list

zypper cheat sheet

Frequently forgotten zypper commands:
  • zypper packages -i [REPO] (list all installed packages from REPO) Note on the 'i' and 'v' letters in the first column: the 'i' means "Installed", which is clear enough. The 'v' means "Another version installed", or in other words: multiple versions of this package are currently available from different repos _and_ a version from a different repo is installed. Note that this does not help if you want to list packages for which zypper shows the repo as "System Packages". In reality, these packages have no repo associated with them - i.e. they were installed from some repo that has since been removed.
  • List packages not associated with any repo:
    zypper se -s --installed|awk '/System Packages/ { print $3 }'
  • Remove all packages not associated with any repo (note: make sure to run zypper up first!):
    zypper rm $(zypper se -s --installed|awk '/System Packages/ { print $3 }')
  • zypper search -s [STRING] (search for packages matching STRING and show details such as 'i'/'v' letters explained above, version, and repository name)
  • zypper search --requires [STRING] (list packages that require packages matching STRING)
  • zypper search --recommends [STRING] (list packages that recommend packages matching STRING)

No comments:

Post a Comment