Zypper Command To Manage Packages On openSUSE & suse Systems

Zypper is a command line package manager for suse & openSUSE distributions. It’s used to install, update, search & remove packages & manage repositories, perform various queries, and more. Zypper command-line interface to ZYpp system management library (libzypp). Some other package manger utilities which are being used widely in Linux are yum, dnf, apt-get, dpkg, rpm, Zypper, pacman, etc.,

Now, i’m going to play on our openSUSE Leap 42.1 box to explain and cover mostly used Zypper commands with examples. In zypper we can use shotcode also like (in instead of install) like that for all commands.

1) Common syntax/file location for Zypper

See below for common syntax/ file location of Zypper.

# General syntax for Zypper #
zypper [global-options] command [command-options] [arguments] ...

# most popular zypper commands #
[install remove patch source-install search verify update list-updates repos refresh lr]

# zypper config file location #
/etc/zypp/zypper.conf

# zypper cached file location #
/var/cache/zypp

# zypper history file location #
/var/log/zypp/history

2) Install a Package or packages

Use the below command to install any package or packages on your system. In this case i’m going to install apache, MariaDB-server, MariaDB-client. Every time zypper ask your confirmation to install the corresponding package. if you want to avoid the confirmation you can do by this adding -y option with zypper.

# Install a single package #
# zypper install apache2
or
# zypper -y in apache2

# Install more than one packages #
# zypper install MariaDB-server MariaDB-client
or
# zypper -y in MariaDB-server MariaDB-client

# Install a particular version of package #
# zypper install nano-2.4.2-4.2

# Install a package using wildcards #
# zypper install nano-*

# Install a package with specific architecture #
# zypper install 'nano.x86_64'

# Install a higher version of package which is given here #
# zypper install 'nano>=2.3.3-3.3'

# Install a higher version of package which is given here with particular architecture #
# zypper install 'nano.x86_64>=2.3.3-3.3'

# Install a package from rpm file (local Path) #
# zypper install /opt/skype-4.3.0.37-suse.i586.rpm

# Install a package from rpm file (Remote Path) #
# zypper install wget http://download.skype.com/linux/skype-4.3.0.37-suse.i586.rpm

# To install and remove packages simultaneously (To install emacs and remove vim simultaneously) #
# zypper install emacs -vim
or
# To remove emacs and install vim simultaneously #
# zypper remove emacs +vim

3) Remove a Package or packages

Use the below command to remove/erase any package or packages on your system. In this case I’m going to remove apache, MariaDB-server, MariaDB-client.

# Remove a single package #
# zypper remove apache2
or
# zypper re apache2

# Remove more than one packages #
# zypper remove MariaDB-server MariaDB-client
or
# zypper re MariaDB-server MariaDB-client

4) update a Package or packages

Use the below command to update any package or packages on your system. In this case I’m going to update nano, MariaDB-server, MariaDB-client to latest version.

# update single package #
# zypper update nano
or
# zypper up nano

# update more than one packages #
# zypper update MariaDB-server MariaDB-client nano
or
# zypper up MariaDB-server MariaDB-client nano

5) Zypper Repository Management

The below list of commands will help you to manage zypper repository. Here i’m going to show you complete repository management commands such as (Refresh repo, list repo, enable repo & disable repo)

# Refresh repository packages #
# zypper refresh
or
# zypper ref
Repository 'packman-repository' is up to date.                        
Repository 'google-chrome' is up to date.                             
Repository 'Stable Quod Libet / Ex Falso Builds (openSUSE_42.1)' is up
Repository 'openSUSE-leap/42.1-Non-Oss' is up to date.                
Repository 'openSUSE-leap/42.1-Oss' is up to date.                    
Repository 'openSUSE-42.1-Update' is up to date.                      
Repository 'openSUSE-42.1-Update-Non-Oss' is up to date.              
All repositories have been refreshed.

1) List Repositories

# List Repositories #
# zypper repos
# | Alias                 | Name                                                | Enabled | GPG Check | Refresh
--+-----------------------+-----------------------------------------------------+---------+-----------+--------
1 | packman-repository    | packman-repository                                  | Yes     | (r ) Yes  | Yes    
2 | google-chrome         | google-chrome                                       | Yes     | (r ) Yes  | Yes  
3 | home_lazka0_ql-stable | Stable Quod Libet / Ex Falso Builds (openSUSE_42.1) | Yes     | (r ) Yes  | No      
4 | repo-non-oss          | openSUSE-leap/42.1-Non-Oss                          | Yes     | (r ) Yes  | Yes    
5 | repo-oss              | openSUSE-leap/42.1-Oss                              | Yes     | (r ) Yes  | Yes    
6 | repo-update           | openSUSE-42.1-Update                                | Yes     | (r ) Yes  | Yes    
7 | repo-update-non-oss   | openSUSE-42.1-Update-Non-Oss                        | Yes     | (r ) Yes  | Yes

2) List Repositories with URI

# List Repositories with URI #
# zypper lr -u
# | Alias                 | Name                                                | Enabled | GPG Check | Refresh | URI                                                                             
--+-----------------------+-----------------------------------------------------+---------+-----------+---------+---------------------------------------------------------------------------------
1 | packman-repository    | packman-repository                                  | Yes     | (r ) Yes  | Yes     | http://ftp.gwdg.de/pub/linux/packman/suse/openSUSE_Leap_42.1/                   
2 | google-chrome         | google-chrome                                       | Yes     | (r ) Yes  | Yes     | http://dl.google.com/linux/chrome/rpm/stable/x86_64                             
3 | home_lazka0_ql-stable | Stable Quod Libet / Ex Falso Builds (openSUSE_42.1) | Yes     | (r ) Yes  | No      | http://download.opensuse.org/repositories/home:/lazka0:/ql-stable/openSUSE_42.1/
4 | repo-non-oss          | openSUSE-leap/42.1-Non-Oss                          | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/distribution/leap/42.1/repo/non-oss/               
5 | repo-oss              | openSUSE-leap/42.1-Oss                              | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/distribution/leap/42.1/repo/oss/                   
6 | repo-update           | openSUSE-42.1-Update                                | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/update/leap/42.1/oss/                              
7 | repo-update-non-oss   | openSUSE-42.1-Update-Non-Oss                        | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/update/leap/42.1/non-oss/

3) List Repositories by priority

# List Repositories by priority #
# zypper lr -p
# | Alias                 | Name                                                | Enabled | GPG Check | Refresh | Priority
--+-----------------------+-----------------------------------------------------+---------+-----------+---------+---------
1 | packman-repository      | packman-repository                                  | Yes     | (r ) Yes  | Yes     |   99    
2 | google-chrome         | google-chrome                                       | Yes     | (r ) Yes  | Yes     |   99    
3 | home_lazka0_ql-stable | Stable Quod Libet / Ex Falso Builds (openSUSE_42.1) | Yes     | (r ) Yes  | No      |   99    
4 | repo-non-oss          | openSUSE-leap/42.1-Non-Oss                          | Yes     | (r ) Yes  | Yes     |   99    
5 | repo-oss              | openSUSE-leap/42.1-Oss                              | Yes     | (r ) Yes  | Yes     |   99    
6 | repo-update           | openSUSE-42.1-Update                                | Yes     | (r ) Yes  | Yes     |   99    
7 | repo-update-non-oss   | openSUSE-42.1-Update-Non-Oss                        | Yes     | (r ) Yes  | Yes     |   99 

4) Refresh a Specific Repository

# Refresh a specific repository #
# zypper refresh packman-repository
Repository 'packman-repository' is up to date.                        
Specified repositories have been refreshed.

5) Disable a Specific Repository

# Disable a specific repository #
# zypper mr -d 1
Repository 'google-chrome' has been successfully disabled.

# zypper lr
# | Alias                 | Name                                                | Enabled | GPG Check | Refresh
--+-----------------------+-----------------------------------------------------+---------+-----------+--------
1 | google-chrome         | google-chrome                                       | No      | ----      | Yes    
2 | home_lazka0_ql-stable | Stable Quod Libet / Ex Falso Builds (openSUSE_42.1) | Yes     | (r ) Yes  | No     
3 | packman-repository    | packman-repository                                  | Yes     | (r ) Yes  | No     
4 | repo-non-oss          | openSUSE-leap/42.1-Non-Oss                          | Yes     | (r ) Yes  | Yes    
5 | repo-oss              | openSUSE-leap/42.1-Oss                              | Yes     | (r ) Yes  | Yes    
6 | repo-update           | openSUSE-42.1-Update                                | Yes     | (r ) Yes  | Yes    
7 | repo-update-non-oss   | openSUSE-42.1-Update-Non-Oss                        | Yes     | (r ) Yes  | Yes

6) Enable a Specific Repository

# Enable a specific repository #
# zypper mr -e 1
Repository 'google-chrome' has been successfully enabled.

7) Add a New Repository to System

# Add a new repo to system #
# zypper addrepo http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_42.1/ packman-repository
or
# zypper ar http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_42.1/ packman-repository

8) Remove a Repository from System

# Remove a repo from system #
# zypper removerepo packman-repository
or
# zypper rr packman-repository
or
# zypper removerepo repo-no
Removing repository 'packman-repository' .......................[done]
Repository 'packman-repository' has been removed.

6) How to list packages

Use the below commands to list all packages, products & patterns which are available in all repository. I have enabled Packman & Google Chrome, so in this case it shows all the repository packages.

# List all products packages #
zypper products

# List pattern of packages, like lamp-server will contain (apache, MariaDB, php & phpMyAdmin) #
zypper patterns

# List all repository packages #
zypper packages

7) Search a package

If you don’t know the exact package name which you want to install, Use the search option it will return the matching string. In this case I’m going to search ftpd.

# Search a package #
# zypper search ftp
or
# zypper se ftp
Loading repository data...
Reading installed packages...
S | Name           | Summary                                 | Type   
--+----------------+-----------------------------------------+--------
  | proftpd        | Highly configurable GPL-licensed FTP -> | package
  | proftpd-devel  | Development files for ProFTPD           | package
  | proftpd-doc    | Documentation for ProFTPD               | package
  | proftpd-lang   | Languages for package proftpd           | package
  | proftpd-ldap   | LDAP Module for ProFTPD                 | package
  | proftpd-mysql  | MySQL Module for ProFTPD                | package
  | proftpd-pgsql  | PostgreSQL Module for ProFTPD           | package
  | proftpd-radius | Radius Module for ProFTPD               | package
  | proftpd-sqlite | SQLite Module for ProFTPD               | package
  | pure-ftpd      | A Lightweight, Fast, and Secure FTP S-> | package
  | vsftpd         | Very Secure FTP Daemon - Written from-> | package

The above output shows matching string for ftpd.

8) Check package information

If you want to know the package detailed information before proceeding with the installation. Use the below command, it will give full information about the package like package version, size, repo name, etc..

# print package info #
# zypper info apache2
Loading repository data...
Reading installed packages...

Information for package mpv:
----------------------------
Repository: packman-repository
Name: mpv
Version: 0.15.0-36.1
Arch: x86_64
Vendor: http://packman.links2linux.de
Installed: Yes
Status: out-of-date (version 0.14.0-29.3 installed)
Installed Size: 2.0 MiB
Summary: Advanced general-purpose multimedia player
Description: 
  mpv is a movie player based on MPlayer and mplayer2. It supports a
  wide variety
  of video file formats, audio and video codecs, and subtitle types.

9) Install a package from particular Repository

Use the below command to Install a package from particular Repository. In this case I’m going to install mplayer package from packman repository.

# Install a package from particular Repository #
# zypper -v install --from packman-repository mplayer

10) Install/Repair missing dependencies

Use the below command to Install/Repair missing dependencies.

# Verify missing dependencies #
# zypper verify

# Install/Repair missing dependencies #
# zypper install-new-recommends

11) Install Patches

Use the below commands to List/Install all officially released patches to your system. Optionally, you can specify a bug number or CVE issue.

# Lists the number of needed patches #
# zypper patch-check
Loading repository data...
Reading installed packages...
21 patches needed (11 security patches)

# Lists all needed patches with detailed info #
# zypper list-patches
Loading repository data...
Reading installed packages...

Repository           | Name             | Category    | Severity  | Interactive | Status | Summary                                       
---------------------+------------------+-------------+-----------+-------------+--------+-----------------------------------------------
openSUSE-42.1-Update | openSUSE-2016-10 | security    | important | ---         | needed | Security update for grub2                     
openSUSE-42.1-Update | openSUSE-2016-13 | security    | moderate  | ---         | needed | Security update for phpMyAdmin                
openSUSE-42.1-Update | openSUSE-2016-17 | recommended | moderate  | ---         | needed | Recommended update for shim-TW                
openSUSE-42.1-Update | openSUSE-2016-21 | recommended | important | ---         | needed | Recommended update for Mesa                   
openSUSE-42.1-Update | openSUSE-2016-23 | recommended | important | ---         | needed | Recommended update to KDE Applications 15.12.0
openSUSE-42.1-Update | openSUSE-2016-28 | security    | moderate  | ---         | needed | Security update for libpng16 

# To install all officially released patches #
# zypper patch

12) Update Packages

Use the below commands to update entire system packages to latest version except Patches. Also we can upgrade our system to new version of opensuse if its available.

# List the available updates (only installed pacakges) #
# zypper list-updates
Loading repository data...
Reading installed packages...
S | Repository           | Name                      | Current Version              | Available Version           | Arch  
--+----------------------+---------------------------+------------------------------+-----------------------------+-------
v | packman-repository   | ffmpeg                    | 2.8.4-45.1                   | 2.8.5-53.1                  | x86_64
v | google-chrome        | google-chrome-stable      | 47.0.2526.106-1              | 48.0.2564.82-1              | x86_64
v | packman-repository   | mpv                       | 0.14.0-29.3                  | 0.15.0-36.1                 | x86_64
v | openSUSE-42.1-Update | openssh                   | 6.6p1-6.3                    | 6.6p1-8.1                   | x86_64
v | openSUSE-42.1-Update | openssh-helpers           | 6.6p1-6.3                    | 6.6p1-8.1                   | x86_64
v | openSUSE-42.1-Update | phpMyAdmin                | 4.4.15.1-3.1                 | 4.4.15.2-8.1                | noarch

# List the available updates (regardless whether installable or not) #
# zypper list-updates --all

# To upgrade/update particular pacakge #
# zypper update package_name
or
# zypper install package_name

# update entire system packages to latest version #
# zypper update
or
# zypper up

# Upgrading to a New Product Version #
# zypper dist-upgrade

13) Rebuild repositories database

In case after zypper refresh you will not get the package which is exist on repo, try to force refresh & rebuild the repo database, including a forced download of raw metadata.

# Rebuild repositories database #
# zypper refresh -fdb

14) Clean Zypper Cache

If we want to clean zypper cache we can do it, optionaly we can clean metadata and package cache.

# Clean Zypper Cache #
# zypper clean

# clean metadata and package cache #
# zypper clean -a
or
# zypper clean --all

15) How to install pattern package

We can install pattern package, like if you want to install group of software in one shot.

# install pattern package #
# zypper in -t pattern mate

16) How to Enable caching

We can enable rpm files caching for all repository.

# Enable RPM file caching #
# zypper mr -ka

17) How to get help from zypper

We can get verity of help from zypper commands.

# Print list of all global options and commands #
# zypper

# Print particular command options #
# zypper help command

Enjoy….)

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...

Shares
Close
Please support the site
By clicking any of these buttons you help our site to get better