Return to Level1Techs.com

A compendiary overview of Zypper {WIKI}

As per request of the young lady @MisteryAngel a zypper overview and tutorial is apparently very sought after. So lets’s begin.

@wendell feel free to include any insights into things you discovered about zypper if any.

**Disclaimer. Dear All, I do not write many user friendly tutorials often so please let me know in the comments where I am not clear or you need clarification on.

Regards,
Heimdallr

#Table of Contents

  1. What is Zypper?
  2. The Command Itself
  3. Repository Management
  4. Package Management
  5. Scripting with Zypper
  6. Querying or Searching for Packages
  7. Utilities
  8. Package Locking
  9. Update Management
  10. Distribution Upgrades
  11. Frequently Used Vocabulary (FUV)
  12. [Reserved] (A compendiary overview of Zypper {WIKI})

@wendell seems we have some bugs. Some posts are auto replying to each other because of a quote? LOL that’s amusing.

10 Likes

What is zypper?

Zypper is the linux distribution openSUSE's package manager command line interface (CLI) which is essentially a collection of programs and tools that automate the process of installing, upgrading, configuring, and removing computer programs/tools/kernels for a computer's operating system in a consistent manner and orderly manner. It contains everything needed to resolve 95 percent of software installation and removal cases.

Can you only modify software in the command line on OpenSUSE?

Of course not. While a lot of distributions focus on keeping some of the purity of linux, OpenSUSE does not have that luxury. OpenSUSE has a very well known enterprise variant called SUSE Linux Enterprise or SLES. This inherently steers OpenSUSE's direction of development a good portion of the time and thus YAST was created. YaST (Yet another Setup Tool) is the graphical front end for Zypper. YAST is a topic for another day so we will begin going over most of the functions Zypper has in the CLI.

3 Likes

The command itself

  • NOTICE: all zypper instances must be ran in SUDO or SU. Zypper can be found in /usr/sbin/ which means it must be ran with administrator privileges. Please remember this for the rest of the tutorial

zypper
The command that initiates zypper. This calls the program.
zypper help [command]
This is similar to the "not so helpful" man pages. It can run general help on all zypper functions or a specific command and its arguments. It is a very long help file and it is best used in a scrollable terminal shell.
zypper sh
This opens a zypper shell session which allows you to just run zypper commands

Here is an example of what that looks like in your terminal or Konsole or Xterm or whatever special snowflake name you have chosen to give it
[email protected]~: zypper sh
zypper>
zypper>
zypper>
zypper>quit
zypper exiting
[email protected]~:

2 Likes

Repository Management

Well at this point we need to add a repository. For those who are not familiar with linux and are starting with OpenSUSE. First off I would like to say. GOOD FOR YOU! You wont regret it. It's good to break away from the common route. It might just be more rewarding. Back to my original point. You would probably guess this already but a repository is a storage location from which most of your software packages can be retrieved for installation. Now be careful adding repositories to your linux distribution. Sometimes its not always wise. While most developers and distributions do not inject malicious code, some third party repos may contain it so be wise with your additions. A good overview can be found here.

Lets begin with Repository management now.

If you ever feel the need to list your already defined repositories. You may run the following command.

zypper lr -- This CAT's all your repositories names to the terminal display window. The following arguments can be appended for additional functionality.

  • -u -- This will include the URL of the repo if you want to check your it with the real URL in case of a possible typographical mistake.

  • -P Likely unique to RHEL, SLES, and OpenSUSE. This argument allows you to check the priority of the repository. The priority is the order in which packages will be installed. If one is higher priority then it will pull the package from that repository instead of one that maybe lower than it. This can be useful when a third party repository contains a version of a package you would like to install over the default included repositories of the distribution.

The following section will be about modifying repositories with zypper.

zypper mr [repository name] -- This will modify any of the parameters of the specified repository. The following arguments can be used to change any of these parameters

  • -d [number of repo] -- This argument will disable the specified (by number) repository

  • -rk -p [priority=level] [repo name] -- Example Provided below. This will enable auto refresh on this repository as well as caching it to your system and it also sets the repository's priority to 52
    zypper mr -rk -p 52 firefox

  • -Ka -- Disables RPM caching... Upon installation the install files will be deleted. Useful for minimal installation systems

  • -kt -- Enables RPM caching only for remote repositories. Good if you need to diagnose a package and the PC does not have a reliable internet connection.

  • zypper lr --export [Directory]/[name].repo -- exports your repo list or the repo to a directory.

Adding Repositories
zypper ar [url of repository] {space} [user defined name]
-- Fairly straight forward. Adds the repository at the URL. It looks for a .repo file so make sure thats in the URL root directory. Then you may specify a name.

zypper ar --export [Directory]/[name].repo -- imports a repo from a directory.

Removing Repositories
zypper rr [name of repository] -- Removes the repository with the specified name. (DUH) sorry no I know its not obvious sometimes but its that moment when you think to yourself. Fuck im a retard could have guessed that LOL.

Refreshing your list or updating your repo list

Just like with APT's sudo apt-get update. We can also refresh all repos by running this command. Of course we can also name a repository afterwards or force an update of a repo with the following -f argument with the name following

here is the base command

zypper up [argument] [repo name] or just zypper up

2 Likes

Package Management

It's all fun and games until something breaks" ~CynicRF 2015

Selecting and Installing Packages

zypper in [argument] -- Selects the following packages based on your argument. Arguments are provided below

  • [[package name] -- installs by package naming capability. AKA PERL installs the perl programming language.

  • [package]<[version of package] or [package.architecture=version] -- Basically this is an over constructed command to install by architecture and name and the version you desire.

  • [-n] [name] installs by the EXACT name of the package and not just its capability

  • [repo:name] -- Installs specific package from specific repository

  • [* [package name or guessed name] *] -- "Lets wild card this bitch because I do not know what the fuck just happened and I can't to save my life remember that stupid fucking packages name" ~ CynicRF 2002-2015 LOL ..
    -- As my quote implies the wild card will install all packages with this in its name. DO not use this frequently. Only use it as a last resort and it may not work thanks to version checking issues.

  • [rpm name] -- installs the specific rpm.

  • -t pattern [name of pattern] -- installs a slew of packages based on a pattern of installation. Useful for installing LAMP among other things.

  • [new package name] -[old package name for removal] If you need to install a package that replaces another packages functionality. This is useful for doing so as well as removing the obsolete package

  • [package name1] {space} [package name2] {space} [package name3] {space} [package name4] -- installing multiple packages has never really changed. That is how you do it

Removing Packages

zypper rm [package] -- no other different commands other than this can be ran. It simply uninstalls the package.

Installing from Source

LOL^_^ Irony am I right?

zypper si [arguments] [package name] -- base command that installs from source. There are two arguments with this command. CAPS are important

  • -D -- Only installs source package ignoring dependencies. [Have fun ;) xP ]

  • -d -- Only installs dependencies - Useful for dependency issues.

Updating Packages

zypper up or zypper up [package] -- Updates all packages or a specified few. You can also use the in command it will go to the latest version unconditionally and install if not already installed on the system.

2 Likes

Scripting with Zypper

(Applicable to all scripts sh, bash, etc)
at this point if you are writing scripts this is just a helpful reference and I will not be very user friendly here. RTM my friends

For all non interactive scripts. You may state the following command to prevent all user input. The patch version skips all patches which have issues and would ultimately need user input

zypper --non-interactive or zypper --non-interactive patch

Running a script without GPG checks. This can be done with the following command
zypper --no-gpg-checks

Want it to auto agree with licenses for a nice automation sequence? We can do that to

zypper --auto-agree-with-licenses

Want to specify your own output (assuming you already know how). This is how you silence zyppers rather verbose output

zypper --quiet

Want to log the entire process in an XML file. Let's DOOOO EEET!

zypper --xmlout [name.xml] [arguments ran]

More information to come later. Theres a lot you can do but this is suppose to cover the basics. For more information please refer to SUSE's documentation https://en.opensuse.org/SDB:Zypper_usage

2 Likes

Querying Packages

Searching
zypper se [arguments]

  • -dC --match-words [words] -- Find packages with these keywords in their summary

  • 'yast*' -- Hey there's my pet the wild card again. Good Boy you rescued us again. This shows all packages with this in their name

  • -r [repo name] -- shows all packages in that repository

  • -i [package name] -- see all package named similarly to the name that are installed

  • -t pattern -r [repo name] -- List all patterns in this repo specificied

Got Info?

zypper info [package] or zypper info [patch] [package] -- Gets information on a specific package or patch to a package. Sometimes you get a nice changelog.

Want information on dependencies? This is rather unique to OpenSUSE as far as I know.

zypper what-provides [package] or zypper wp [package] -- Provides dependency list and information for the specified package.

2 Likes

Utilities for diagnosing broken systems

There are two utilities at your disposal. A verify tool to verify the integrity of installed packages and an install all recommendations tool.

Verifying Packages

zypper verify -- verifies all packages on the system and lists all issues currently occurring and why they are occurring as well as possible solutions to the issue if any. It practically tells you have to fix your system

Installing all recommended packages
zypper install-new-recommends or zypper inr -- Installs all recommended packages for full functionality of a program you have or have not already fully installed on your system.

2 Likes

Package Locking

So why would you want to lock a package? Well maybe its more stable than its update. Maybe you are trying to keep functionality that got removed or broken in the next update. This will be what you want to run.

"al can be used instead of addlock"

zypper addlock [package] -- locks specified package

"rl can be used instead of removelock"

zypper removelock [package] -- unlocks the specified package allowing updates to be performed

List Locking. We can lock an entire list of programs by running the locks command which locks all the packages lists afterwards

zypper locks [package list]

2 Likes

Update Management

Listing Needed Patches
zypper list-patches -- Lists only needed patches
or
zypper lp

Applying Patches
zypper patch -- Applies all patches to all programs

Listing all Patches
zypper patches -- Lists all patches necessary and unecessary

Checking Patches
zypper patch-check [package] -- checks for package patches on specified package
or
zypper pchk -- checks patches for integrity

Getting Information About Patches

zypper patch-info -- Gets the information on a specific package patch
zypper info -t patch -- same as above

Got Updates?
zypper list-updates -- Lists all updates
or
zypper lu -- same as above
or
zypper update -- Updates all packages
or
zypper up --same as above

2 Likes

Distribution Upgrades

I made a section for this because I defer from opensuse's official process a bit.

first we will want to run

zypper refresh

then

zypper up

then finally here is the distribution upgrade command

zypper dup -- Upgrades the system to the latest stable release. Or if on tumbleweed it will upgrade you to the next daily if you havent already.

2 Likes

Frequently Used Vocabulary (FUV)

Repositories: HTTP or FTP server, DVD, or a folder on a local disc.
where a group or set of packages are located.

Resource Identfiers (URI): To specify locations of repositories or other resources (RPM files, .repo files) you can use any type of URIs
supported by libzypp. See http://en.opensuse.org/
Libzypp/URI for a complete list and usage examples.

Refresh: Refreshing a repository means downloading metadata
of packages from the medium (if needed), storing it in
local cache (typically under /var/cache/zypp/raw/
directory) and preparsing the metadata
into .solv files (building the solv cache), typically under
/var/cache/zypp/solv/.

Services: Services are one level above repositories and serve to
manage repositories or to do some special tasks.
Libzypp currently supports only one type of services, the
Repository Index Service (RIS).

Package Types: zypper works with several types of resource objects, called resolvable. A resolvable is a package, patch, pattern, or a product.

package: an ordinary RPM package

patch: update of one or more packages.

pattern: group of packages required or recommended to install some functionality

product: group of packages which are necessary to install a product

2 Likes

SOURCES
https://en.opensuse.org/SDB:Zypper_usage
https://en.opensuse.org/SDB:Manual_pages

Lots of personal experience

The memes should suffice

4 Likes

Just a few things I want to point out.

A good number of these commands will actually run without root privileges. Any time you are trying to do a search or your want to list out your repos, you do not have to run root. However if you want zypper to change something, then you will need root privilege.

Also, you almost never need to use zypper ref. Most zypper commands will auto refresh the repos ONLY IF THE REPOS ARE OUT OF DATE.

This is probably the coolest thing about zypper. It actually knows when it should refresh the repos or not.

With Apt, DNF, and several other package managers, they will just either auto refresh every time, or not at all and you have to refresh the repos yourself.

1 Like

I didnt forget those. I just ran out of edits. I literally can not edit for 24 hours because I hit a discourse limit. Its a bit retarded. but yeah I love zypper.

About the root stuff. Whenever I run zypper I just get in the habit of starting with a sudo -i or a sudo -v.

Thanks for the feedback @Tjj226_Angel

2 Likes

Great overview. It doesn't look like you missed anything. It's IMO the best package manager, and it's great to see someone posting a tutorial for those converting to it

Well I figure that its amongst one of the more complex package managers. I may take a break for a bit. Maybe Ill do a yast tutorial? ehhh anyways yup NP. I definitely wanted to see a zypper write up on here.

1 Like

Nice post, you really get to the root of this stuff.

1 Like

DNF and Apt 1.1 are now a lot more like zypper.

You kind of have to change some settings and really mess around with it a bit, but yeah. Everyone seems to have acknowledged the power of zypper and is trying to copy it in one way or another.

Oh yeah they are always pulling a Microsoft or an Apple here and there. I think its power comes from the fact that they took the best of SLACKWARE and RHEL then put it together in a rather unique form. Of all the RHEL based distros, OpenSuse is my favorite.

Also Thanks @wyrm I try. ;)

1 Like