Zypper Command Examples

Managing Packages with Zypper

Zypper - command line interface


zypper is a command line interface to the native ZYpp package manager. zypper is predominantly found on SLES (SUSE Linux Enterprise Server) and openSUSE distributions. zypper is used for installing, removing, updating and querying software packages.



Software Management


Installing Packages: zypper install packagename



linux-pd5y:~ # zypper install htop
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
  htop 

1 new package to install.
Overall download size: 63.0 KiB. After the operation, additional 141.0 KiB will be used.
Continue? [y/n/?] (y): y
Retrieving package htop-0.9-16.1.3.i586 (1/1), 63.0 KiB (141.0 KiB unpacked)
Retrieving: htop-0.9-16.1.3.i586.rpm [done]
Installing: htop-0.9-16.1.3 [done]

The package "htop" has been installed by specifying the "install" option. You can use the shortened version of the same command "zypper in htop".

Removing Packages: zypper remove packagename



linux-pd5y:~ # zypper remove htop
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following package is going to be REMOVED:
  htop 

1 package to remove.
After the operation, 141.0 KiB will be freed.
Continue? [y/n/?] (y): y
Removing htop-0.9-16.1.3 [done]

The above "remove" option removes the specified package. Again, this command can be shortened to "zypper rm htop".

Display Repositories: zypper repos



linux-pd5y:~ # zypper repos
# | Alias                              | Name                               | Enabled | Refresh
--+------------------------------------+------------------------------------+---------+--------
1 | Updates-for-openSUSE-12.1-12.1-1.4 | Updates for openSUSE 12.1 12.1-1.4 | Yes     | Yes    
2 | openSUSE-12.1-12.1-1.4             | openSUSE-12.1-12.1-1.4             | Yes     | No     
3 | repo-debug                         | openSUSE-12.1-Debug                | No      | Yes    
4 | repo-debug-update                  | openSUSE-12.1-Update-Debug         | No      | Yes    
5 | repo-non-oss                       | openSUSE-12.1-Non-Oss              | Yes     | Yes    
6 | repo-oss                           | openSUSE-12.1-Oss                  | Yes     | Yes    
7 | repo-source                        | openSUSE-12.1-Source               | No      | Yes 

List Available Updates: zypper list-updates



linux-pd5y:~ # zypper list-updates
Loading repository data...
Reading installed packages...
S | Repository                         | Name                                 | Current Version           | Available Version         | Arch  
--+------------------------------------+--------------------------------------+---------------------------+---------------------------+-------
v | Updates for openSUSE 12.1 12.1-1.4 | MozillaFirefox                       | 17.0-2.54.1               | 19.0-2.62.1               | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | MozillaFirefox-translations-common   | 17.0-2.54.1               | 19.0-2.62.1               | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | ca-certificates-mozilla              | 1.85-3.7.1                | 1.85-3.11.1               | noarch
v | Updates for openSUSE 12.1 12.1-1.4 | chromium                             | 25.0.1362.0-1.47.1        | 26.0.1383.0-1.51.1        | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | chromium-desktop-kde                 | 25.0.1362.0-1.47.1        | 26.0.1383.0-1.51.1        | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | chromium-ffmpegsumo                  | 25.0.1362.0-1.47.1        | 26.0.1383.0-1.51.1        | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | chromium-suid-helper                 | 25.0.1362.0-1.47.1        | 26.0.1383.0-1.51.1        | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | coreutils                            | 8.14-3.15.1               | 8.14-3.19.1               | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | dhcp                                 | 4.2.4.P2-0.6.13.1         | 4.2.4.P2-0.6.17.1         | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | dhcp-client                          | 4.2.4.P2-0.6.13.1         | 4.2.4.P2-0.6.17.1         | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | flash-player                         | 11.2.202.258-38.1         | 11.2.202.273-54.1         | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | flash-player-kde4                    | 11.2.202.258-38.1         | 11.2.202.273-54.1         | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | fontconfig                           | 2.8.0-24.14.2             | 2.8.0-24.17.1             | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | gconf-polkit                         | 3.2.0-2.2.2               | 3.2.3-2.6.1               | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | gconf2                               | 3.2.0-2.2.2               | 3.2.3-2.6.1               | i586  
v | Updates for openSUSE 12.1 12.1-1.4 | gconf2-branding-openSUSE             | 12.1-6.1.2                | 12.1-6.3.1                | noarch
v | Updates for openSUSE 12.1 12.1-1.4 | gnome-online-accounts                | 3.2.1-2.1.2               | 3.2.1-2.4.1               | i586  
 

The above displays currently installed software along with its version number and also what the latest available version of the software is available. The above example of the output has been shortened as the full listing is considerable in size.

Update Packages: zypper update



linux-pd5y:~ # zypper update
Loading repository data...
Reading installed packages...

The following NEW package is going to be installed:
  gconf2-lang 

The following packages are going to be upgraded:
  MozillaFirefox MozillaFirefox-translations-common ca-certificates-mozilla chromium chromium-desktop-kde chromium-ffmpegsumo 
  chromium-suid-helper coreutils dhcp dhcp-client flash-player flash-player-kde4 fontconfig gconf-polkit gconf2 
  gconf2-branding-openSUSE gnome-online-accounts java-1_6_0-openjdk kde4-kgreeter-plugins kdebase4-workspace 
  kdebase4-workspace-ksysguardd kdebase4-workspace-liboxygenstyle kdelibs4 kdelibs4-core kdm kernel-default krb5 kwin 
  libfreebl3 libfreetype6 libgnutls28 libgoa-1_0-0 libgoa-backend-1_0-0 libgudev-1_0-0 libkde4 libkdecore4 libksuseinstall1 
  libldb1 libmysqlclient18 libmysqld18 libntfs-3g81 libopenssl1_0_0 libqt4 libqt4-qt3support libqt4-sql libqt4-sql-sqlite 
  libqt4-x11 libsmbclient0 libsoftokn3 libtalloc2 libtdb1 libtevent0 libtiff3 libudev0 libv8-3 libwbclient0 mozilla-nspr 
  mozilla-nss mozilla-nss-certs mysql-community-server mysql-community-server-client mysql-community-server-errormessages 
  ntfs-3g ntfsprogs openssl python-kdebase4 samba samba-client sysconfig systemd systemd-sysvinit timezone timezone-java udev 
  virtualbox-guest-kmp-default virtualbox-guest-tools virtualbox-guest-x11 xorg-x11-Xvnc xorg-x11-server 

79 packages to upgrade, 1 new.
Overall download size: 218.0 MiB. After the operation, additional 31.4 MiB will be used.
Continue? [y/n/?] (y): 

The above "zypper update" command will upgrade all packages. You will need to confirm "y" to continue with the upgrade. Progress of the update will be displayed to your console (see sample of output below>:



Retrieving package kdebase4-workspace-ksysguardd-4.7.2-6.7.1.i586 (1/80), 83.0 KiB (194.0 KiB unpacked)
Retrieving delta: ./i586/kdebase4-workspace-ksysguardd-4.7.2-6.4.1_6.7.1.i586.drpm, 26.0 KiB
Retrieving: kdebase4-workspace-ksysguardd-4.7.2-6.4.1_6.7.1.i586.drpm [done (0 B/s)]
Applying delta: ./kdebase4-workspace-ksysguardd-4.7.2-6.4.1_6.7.1.i586.drpm [done]
Retrieving package libfreebl3-3.14.1-9.21.3.i586 (2/80), 138.0 KiB (363.0 KiB unpacked)
Retrieving delta: ./i586/libfreebl3-3.13.6_3.14.1-9.17.1_9.21.3.i586.drpm, 39.0 KiB
Retrieving: libfreebl3-3.13.6_3.14.1-9.17.1_9.21.3.i586.drpm [done]
Applying delta: ./libfreebl3-3.13.6_3.14.1-9.17.1_9.21.3.i586.drpm [done]

Installing: libfreebl3-3.14.1-9.21.3 [done]
Installing: mozilla-nspr-4.9.4-3.11.1 [done]
Installing: libtiff3-3.9.5-8.13.1 [done]
Installing: libfreetype6-2.4.7-9.1 [done]
Installing: libgnutls28-3.0.3-5.11.1 [done]
Installing: coreutils-8.14-3.19.1 [done]
Installing: libv8-3-3.16.4.0-1.36.1 [done]
Installing: gconf2-3.2.3-2.6.1 [done]
Installing: libntfs-3g81-2011.4.12-3.4.1 [done]
Installing: chromium-ffmpegsumo-26.0.1383.0-1.51.1 [done]
Installing: libtalloc2-2.0.5-34.16.1 [done]
Installing: libtdb1-1.2.9-34.16.1 [done]

Now if we rerun the zypper list-updates command we should see that all packages are now up to date:



linux-pd5y:~ # zypper list-updates
Loading repository data...
Reading installed packages...
No updates found.

Checking for Installed Packages



linux-pd5y:~ # zypper search
S | Name                                                    | Summary                                                                                                                                                         | Type      
--+---------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------
i | 81                                                      | parallel-printer-support: initial release for 12.1                                                                                                              | patch     
  | 844-ksc-pcf                                             | Korean 8x4x4 Johab Fonts                                                                                                                                        | package   
i | AdobeICCProfiles                                        | Adobe ICC Profiles                                                                                                                                              | package   
  | CID-keyed-fonts-MOE                                     | MOE CID-Keyed Fonts (for Traditional Chinese)                                                                                                                   | package   
  | CID-keyed-fonts-Munhwa                                  | Munhwa CID-Keyed Fonts (for Korean)                                                                                                                             | package   
  | CID-keyed-fonts-Wada                                    | Wadalab CID-Keyed Fonts (for Japanese)                                                                                                                          | package   
  | CID-keyed-fonts-WadaH                                   | Wadalab CID-Keyed Fonts (for Rare Japanese Characters)                                                                                                          | package   
  | CodeAnalyst                                             | CodeAnalyst is a Performance Analysis Suite for AMD-based System                                                                                                | package   
i | ConsoleKit                                              | System daemon for tracking users, sessions and seats                                                                                                            | package   
  | ConsoleKit-devel                                        | Developer package for ConsoleKit                                                                                                                                | package   


In the above example we have issued the "zypper search" command. This will list all package information. The output is displayed in a table format. The first column lists the status "S". If an "i" is present then this means that the package has been installed. A "v" means another version has been installed and a blank indicates that the package has not been installed (None of the previous options). The following columns are self explanatory, indicating the name, summary type etc..

As you can imagine there are a lot of packages on most systems so the output would be quite considerable. A more useful option is to supply a pattern or the name of the package that you want to query:



linux-pd5y:~ # zypper search samba
Loading repository data...
Reading installed packages...

S | Name                             | Summary                                                           | Type      
--+----------------------------------+-------------------------------------------------------------------+-----------
  | kdebase3-samba                   | KDE Base package: Windows Connection Module                       | package   
i | samba                            | A SMB/CIFS File, Print, and Authentication Server                 | package   
  | samba                            | A SMB/CIFS File, Print, and Authentication Server                 | srcpackage
i | samba-client                     | Samba Client Utilities                                            | package   
  | samba-devel                      | Libraries and Header Files to Develop Programs with Samba Support | package   
  | samba-doc                        | Samba Documentation                                               | package   
  | samba-doc                        | Samba Documentation                                               | srcpackage
  | samba-krb-printing               | Wrapper binary for kerberized printing                            | package   
  | samba-repo-network_samba_STABLE  | Repository Configuration Files of network:samba:STABLE            | package   
  | samba-repo-network_samba_TESTING | Repository Configuration Files of network:samba:TESTING           | package   
  | samba-winbind                    | Winbind Daemon and Tool                                           | package   
  | xmms2-plugin-samba               | Samba Support for xmms2                                           | package   
i | yast2-samba-client               | YaST2 - Samba Client Configuration                                | package   
i | yast2-samba-server               | YaST2 - Samba Server Configuration                                | package 

From the above example we can see that the product "Samba" has been installed along with the "Yast" configuration modules.



Getting help with zypper


For more information regarding all the possible parameters and options that can be passed to the zypper command, we can issue the "zypper --help" command or consult the "man pages" with the "man zypper" command:



linux-pd5y:~ # zypper --help
  Usage:
        zypper [--global-options] <command> [--command-options] [arguments]

  Global Options:
        --help, -h              Help.
        --version, -V           Output the version number.
        --promptids             Output a list of zypper's user prompts.
        --config, -c <file>     Use specified config file instead of the default.
        --quiet, -q             Suppress normal output, print only error
                                messages.
        --verbose, -v           Increase verbosity.
        --no-abbrev, -A         Do not abbreviate text in tables.
        --table-style, -s       Table style (integer).
        --rug-compatible, -r    Turn on rug compatibility.
        --non-interactive, -n   Do not ask anything, use default answers
                                automatically.
        --non-interactive-include-reboot-patches
                                Do not treat patches as interactive, which have
                                the rebootSuggested-flag set.
        --xmlout, -x            Switch to XML output.

        --reposd-dir, -D <dir>  Use alternative repository definition file
                                directory.
        --cache-dir, -C <dir>   Use alternative directory for all caches.
        --raw-cache-dir <dir>   Use alternative raw meta-data cache directory.
        --solv-cache-dir <dir>  Use alternative solv file cache directory.
        --pkg-cache-dir <dir>   Use alternative package cache directory.

     Repository Options:
        --no-gpg-checks         Ignore GPG check failures and continue.
        --gpg-auto-import-keys  Automatically trust and import new repository
                                signing keys.
        --plus-repo, -p <URI>   Use an additional repository.
        --disable-repositories  Do not read meta-data from repositories.
        --no-refresh            Do not refresh the repositories.
        --no-cd                 Ignore CD/DVD repositories.
        --no-remote             Ignore remote repositories.

     Target Options:
        --root, -R <dir>        Operate on a different root directory.
        --disable-system-resolvables
                                Do not read installed packages.

  Commands:
        help, ?                 Print help.
        shell, sh               Accept multiple commands at once.

     Repository Management:
        repos, lr               List all defined repositories.
        addrepo, ar             Add a new repository.
        removerepo, rr          Remove specified repository.
        renamerepo, nr          Rename specified repository.
        modifyrepo, mr          Modify specified repository.
        refresh, ref            Refresh all repositories.
        clean                   Clean local caches.

     Service Management:
        services, ls            List all defined services.
        addservice, as          Add a new service.
        modifyservice, ms       Modify specified service.
        removeservice, rs       Remove specified service.
        refresh-services, refs  Refresh all services.

     Software Management:
        install, in             Install packages.
        remove, rm              Remove packages.
        verify, ve              Verify integrity of package dependencies.
        source-install, si      Install source packages and their build
                                dependencies.
        install-new-recommends, inr
                                Install newly added packages recommended
                                by installed packages.

     Update Management:
        update, up              Update installed packages with newer versions.
        list-updates, lu        List available updates.
        patch                   Install needed patches.
        list-patches, lp        List needed patches.
        dist-upgrade, dup       Perform a distribution upgrade.
        patch-check, pchk       Check for patches.

     Querying:
        search, se              Search for packages matching a pattern.
        info, if                Show full information for specified packages.
        patch-info              Show full information for specified patches.
        pattern-info            Show full information for specified patterns.
        product-info            Show full information for specified products.
        patches, pch            List all available patches.
        packages, pa            List all available packages.
        patterns, pt            List all available patterns.
        products, pd            List all available products.
        what-provides, wp       List packages providing specified capability.

     Package Locks:
        addlock, al             Add a package lock.
        removelock, rl          Remove a package lock.
        locks, ll               List current package locks.
        cleanlocks, cl          Remove unused locks.

     Other Commands:
        versioncmp, vcmp        Compare two version strings.
        targetos, tos           Print the target operating system ID string.
        licenses                Print report about licenses and EULAs of
                                installed packages.

Type 'zypper help <command>' to get command-specific help.