OpenSUSE Administation with Zypper

Zypper is the command line package manager for openSUSE, introduced in openSUSE 10.2 which uses the libzypp library. Zypper provides a command line interface to manage repositories, the software installation, packages, patches, verifying dependencies etc.

Zypper command groups

Zypper provides a lot of commands. These commands are grouped into the following groups:

Repository management

Commands to manage openSUSE repositories. Add new repository, delete or edit the repository etc.

Service management

Repository Index service management.

Software management

Manage packages and install software. Install or remove packages, verify the integrity of packages etc.

Update management

Update management for openSUSE. Update installed software, install patches for packages, upgrade the openSUSE distribution.

Queries

The zypper query command is used to search for packages by name, show detailed info about packages, list available patches, etc.

Other commands

Other useful zypper commands.

1.The Basic Zypper Command syntax

The basic syntax of zypper is:

zypper command options..

If you need to get help with a command, you can use help:

zypper help command..

Zypper provides a long and short syntax for commands. An example: if you want to install a new package, you can use:

zypper install newpackages

in long syntax or you can use "in" instead "install" for for the short syntax:

zypper in newpackages

2. Repository Management with Zypper

In this section, I will explain how to use the zypper command to manage openSUSE repositories. I will use the zypper command to add a new repository, remove a repository and get a list of all available repositories.

Before we start the case, if you want to see the options of one of the commands, you can use help:

zypper help command..

Case:

We will add the packman repository to openSUSE leap. Packman is the largest external openSUSE repository, it provides packages for multimedia applications, libraries and many other useful packages that for your system.

Add packman repository

Add the packman repository with the "zypper ar" command:

zypper ar -f -n packman http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_42.1/ packman

You can see the results:

Adding repository 'packman' ...................................................................................................................................................[done]
Repository 'packman' successfully added
Enabled     : Yes
Autorefresh : Yes
GPG Check   : Yes
URI         : http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_42.1/

Option - to use zypper help to see the option.

-f = enable auto-refresh the repository

-n = name of the new repository

Now refresh the packman repository:

zypper ref packman

Then check the packman repository and you will see the repository on the list:

zypper lr

zypper list repository command

Modify the packman repository

We can use the "mr" or "modifyrepo" command to alter the repository. There is an option to modify the repository, in this step I will just use the option to enable or disable the repository.

Disable the packman repository without removing the repository:

zypper mr -d packman

If you want to enable it again, you can use the "-e" option:

zypper mr -e packman

To remove the repository completely use:

zypper rr packman

3. Zypper Queries

In this chapter, I will show you how to search for software or packages with the zypper command. The package search is based on the name. The commands will show the details of the package, list available patches, and available updates.

Case:

We want to search for a new package for "mariadb", then get detailed info's about it like size, version, architecture etc.

Search Packages by Name

Search for the mariadb package with the "zypper se" command:

zypper se -n mariadb

zypper search for mariadb package

You can see all packages that have "mariadb" in their name. Choose the packages that you want and get the package details for and use "zypper if" command below to display them:

zypper if mariadb

zypper info about mariadb package

Now you know all available details of the package that you want to install.

Another useful command - see all available patches or update of your system:

zypper pch

4. Software Management with Zypper

Now I will show you how to manage software packages on openSUSE leap with the zypper command. We will install a new package, remove a package and clean packages.

Case:

In the zypper queries section, we searched for MariaDB, now we will install that package.

Install a software package with zypper

Install mariadb with "zypper in" command:

zypper in mariadb mariadb-client

Type "y" to continue the installation.

Install mariadb with zypper in

Next, check that MariaDB is installed and up to date with zypper query command below:

zypper if mariadb mariadb-client

If you want to remove mariadb from your system, use the rm command:

zypper rm mariadb

Uninstall mariadb with zypper rm command

MariaDB has been removed from the system. Now we want to download the MariaDB rpm package with zypper and then install it manually. Before doing these stuff, make sure you clean the repository cache with:

zypper clean

Download the MariaDB rpm with zypper by using the "-d" option:

zypper in -d mariadb

To see the mariadb rpm, check the /var/cache/ directory:

ll /var/cache/zypp/packages/repo-update/x86_64

You will see mariadb.rpm in that directory:

download mariadb rp package with zypper command

To install the rpm package, you can use the rpm command or do it with zypper (automatically retriveving package from local). Go to /var/cache/ directory and install it with zypper:

cd /var/cache/zypp/packages/repo-update/x86_64/
zypper --non-interactive in mariadb-10.0.22-3.1.x86_64.rpm

mariadb installed from rpm package with zypper

Now MariaDB is installed again. This time, we installed it from the previously downloaded rpm package with zypper command.

5. Update Management with Zypper

In this chapter, we will learn more about the update management with Zypper. There are 2 types of updates in openSUSE Leap:

1. Patch-wise

It's an update for anyone using a stable release of openSUSE and wants to update their system with new patches through an online repository. By default, the patch update repository is enabled in the openSUSE, so we do not have to add a new repository.

2. Package-wise

This method installs updates by downloading complete new packages. This is used for general Linux updates, and can be used for updating packages to newer versions from any repository on the system.

Here are some commands to manage updates and patches on openSUSE:

List available Patches with zypper

To see all patches for your system, use the command below:

zypper lp

list available patch for opensuse with zypper lp command

If you want to count the available patches, use the command below:

zypper pchk

count available patches with zypper

there are 138 patches available, 42 of these patches are security related.

To apply/install all patches you can use "patches" command:

zypper patches

List available package updates

To get a list of all available package updates, run this command:

zypper lu -a

list available packages update

If you want to update all packages, you can use "up" or "update" command:

zypper up

The update process will ask for confirmation, type "y" and press enter to download and update all packages. Wait for the update process, it may take some time.

When all updates are installed, restart your openSUSE when the update installed a new Linux Kernel. Then log in again and check the list of updates and patches:

zypper lu -a
zypper lp

Update OpenSUSE

all packages have been updated.

Distribution update

If you want to update (upgrade) your openSUSE to the next major release, you can use "dup" command:

zypper dup

6. Reference

This is just simple guide with the most used commands, I suggest to read more documentation here:

Share this page:

1 Comment(s)

Add comment

Comments

From: harricot

Hi,

The command "zypper patches" doesn't install patches, but prints a list of all possible patches. It has columns with status, importance, etc.

Harrie (@ openSUSE 13.2, kernel 3.16.7-42-desktop)