Zypper is a command line package manager for installing, updating and removing packages a well as for managing repositories. It is especially useful for accomplishing remote software management tasks or managing software from shell scripts.
The general syntax of Zypper is:
zypper [--global-options] COMMAND [--command-options] [arguments]
The components enclosed in brackets are not required. See zypper help for a list of general options and all commands. To get help for a specific command, type zypper help COMMAND.
The simplest way to execute Zypper is to type its name, followed by a command. For example, to apply all needed patches to the system, use:
sudo zypper patch
Additionally, you can choose from one or more global options by typing them immediately before the command:
sudo zypper --non-interactive patch
In the above example, the option --non-interactive means that the command is run without asking anything (automatically applying the default answers).
To use options that are specific to a particular command, type them immediately after the command:
sudo zypper patch --auto-agree-with-licenses
In the above example, --auto-agree-with-licenses is used to apply all needed patches to a system without you being asked to confirm any licenses. Instead, license will be accepted automatically.
Some commands require one or more arguments. For example, when using the command install, you need to specify which package or which packages you want to install:
sudo zypper install mplayer
Some options also require a single argument. The following command will list all known patterns:
zypper search -t pattern
You can combine all of the above. For example, the following command will install the aspell-de and aspell-fr packages from the factory repository while being verbose:
sudo zypper -v install --from factory aspell-de aspell-fr
The --from option makes sure to keep all repositories enabled (for solving any dependencies) while requesting the package from the specified repository.
Most Zypper commands have a dry-run option that does a simulation of the given command. It can be used for test purposes.
sudo zypper remove --dry-run MozillaFirefox
Zypper supports the global --userdata STRING option. You can specify a string with this option, which gets written to Zypper's log files and plug-ins (such as the Btrfs plug-in). It can be used to mark and identify transactions in log files.
sudo zypper --userdata STRING patch
To install or remove packages, use the following commands:
sudo zypper install PACKAGE_NAME sudo zypper remove PACKAGE_NAME
WARNING: Do Not Remove Mandatory System Packages
Do not remove mandatory system packages like glibc , zypper , kernel . If they are removed, the system can become unstable or stop working altogether.
There are various ways to address packages with the commands zypper install and zypper remove.
sudo zypper install MozillaFirefox
sudo zypper install MozillaFirefox-52.2
sudo zypper install mozilla:MozillaFirefox
Where mozilla is the alias of the repository from which to install.
You can select all packages that have names starting or ending with a
certain string. Use wild cards with care, especially when removing
packages. The following command will install all packages starting with
sudo zypper install 'Moz*'
HINT: Removing all -debuginfo Packages
When debugging a problem, you sometimes need to temporarily install a lot of -debuginfo packages which give you more information about running processes. After your debugging session finishes and you need to clean the environment, run the following:
sudo zypper remove '*-debuginfo'
For example, if you want to install a Perl module without knowing the name of the package, capabilities come in handy:
sudo zypper install firefox
Together with a capability, you can specify a hardware architecture and a version:
The name of the desired hardware architecture is appended to the capability after a full stop. For example, to specify the AMD64/Intel 64 architectures (which in Zypper is named x86_64), use:
sudo zypper install 'firefox.x86_64'
Versions must be appended to the end of the string and must be preceded by an operator: < (lesser than), <= (lesser than or equal), = (equal), >= (greater than or equal), > (greater than).
sudo zypper install 'firefox>=52.2'
You can also combine a hardware architecture and version requirement:
sudo zypper install 'firefox.x86_64>=52.2'
You can also specify a local or remote path to a package:
sudo zypper install /tmp/install/MozillaFirefox.rpm sudo zypper install http://download.example.com/MozillaFirefox.rpm
To install and remove packages simultaneously, use the +/- modifiers. To install emacs and simultaneously remove vim , use:
sudo zypper install emacs -vim
To remove emacs and simultaneously install vim , use:
sudo zypper remove emacs +vim
To prevent the package name starting with the - being interpreted as a command option, always use it as the second argument. If this is not possible, precede it with --:
sudo zypper install -emacs +vim # Wrong sudo zypper install vim -emacs # Correct sudo zypper install -- -emacs +vim # Correct sudo zypper remove emacs +vim # Correct
If (together with a certain package), you automatically want to remove any packages that become unneeded after removing the specified package, use the --clean-deps option:
sudo zypper rm PACKAGE_NAME --clean-deps
By default, Zypper asks for a confirmation before installing or removing a selected package, or when a problem occurs. You can override this behavior using the --non-interactive option. This option must be given before the actual command (install, remove, and patch), as can be seen in the following:
sudo zypper --non-interactive install PACKAGE_NAME
This option allows the use of Zypper in scripts and cron jobs.
To install the corresponding source package of a package, use:
zypper source-install PACKAGE_NAME
When executed as root, the default location to install source packages is /usr/src/packages/ and ~/rpmbuild when run as user. These values can be changed in your local rpm configuration.
This command will also install the build dependencies of the specified package. If you do not want this, add the switch -D:
sudo zypper source-install -D PACKAGE_NAME
To install only the build dependencies use -d.
sudo zypper source-install -d PACKAGE_NAME
Of course, this will only work if you have the repository with the source packages enabled in your repository list (it is added by default, but not enabled). See Section 6.1.5, Managing Repositories with Zypper for details on repository management.
A list of all source packages available in your repositories can be obtained with:
zypper search -t srcpackage
You can also download source packages for all installed packages to a local directory. To download source packages, use:
The default download directory is /var/cache/zypper/source-download. You can change it using the --directory option. To only show missing or extraneous packages without downloading or deleting anything, use the --status option. To delete extraneous source packages, use the --delete option. To disable deleting, use the --no-delete option.
Normally you can only install or refresh packages from enabled repositories. The --plus-content TAG option helps you specify repositories to be refreshed, temporarily enabled during the current Zypper session, and disabled after it completes.
For example, to enable repositories that may provide additional -debuginfo or -debugsource packages, use --plus-content debug. You can specify this option multiple times.
To temporarily enable such 'debug' repositories to install a specific -debuginfo package, use the option as follows:
sudo zypper --plus-content debug \ install "debuginfo(build-id)=eb844a5c20c70a59fc693cd1061f851fb7d046f4"
The build-id string is reported by gdb for missing debuginfo packages.
To verify whether all dependencies are still fulfilled and to repair missing dependencies, use:
In addition to dependencies that must be fulfilled, some packages
recommend other packages. These recommended packages are
only installed if actually available and installable. In case recommended
packages were made available after the recommending package has been
installed (by adding additional packages or hardware), use the following
sudo zypper install-new-recommends
This command is very useful after plugging in a Web cam or Wi-Fi device. It will install drivers for the device and related software, if available. Drivers and related software are only installable if certain hardware dependencies are fulfilled.
There are three different ways to update software using Zypper: by
installing patches, by installing a new version of a package or by updating
the entire distribution. The latter is achieved with zypper
dist-upgrade. Upgrading SUSE Linux Enterprise Server is discussed in
Upgrading SUSE Linux Enterprise, (↑Deployment Guide)
To install all officially released patches that apply to your system, run:
sudo zypper patch
All patches available from repositories configured on your computer are checked for their relevance to your installation. If they are relevant (and not classified as optional or feature), they are installed immediately. Note that the official update repository is only available after registering your SUSE Linux Enterprise Server installation.
If a patch that is about to be installed includes changes that require a system reboot, you will be warned before.
The plain zypper patch command does not apply patches from third party repositories. To update also the third party repositories, use the with-update command option as follows:
sudo zypper patch --with update
To install also optional patches, use:
sudo zypper patch --with-optional
To install all patches relating to a specific Bugzilla issue, use:
sudo zypper patch --bugzilla=NUMBER
To install all patches relating to a specific CVE database entry, use:
sudo zypper patch --cve=NUMBER
For example, to install a security patch with the CVE number CVE-2010-2713, execute:
sudo zypper patch --cve=CVE-2010-2713
To install only patches which affect Zypper and the package management itself, use:
sudo zypper patch --updatestack-only
Bear in mind that other command options that would also update other repositories will be dropped if you use the updatestack-only command option.
To find out whether patches are available, Zypper allows viewing the following information:
To list the number of needed patches (patches that apply to your system but are not yet installed), use patch-check:
zypper patch-check Loading repository data... Reading installed packages... 5 patches needed (1 security patch)
This command can be combined with the --updatestack-only option to list only the patches which affect Zypper and the package management itself.
To list all needed patches (patches that apply to your system but are not yet installed), use list-patches:
zypper list-patches Loading repository data... Reading installed packages... Repository | Name | Version | Category | Status | Summary ---------------+-------------+---------+----------+---------+--------- SLES12-Updates | SUSE-2014-8 | 1 | security | needed | openssl: Update for OpenSSL
To list all patches available for SUSE Linux Enterprise Server, regardless of whether they are already installed or apply to your installation, use zypper patches.
It is also possible to list and install patches relevant to specific issues. To list specific patches, use the zypper list-patches command with the following options:
To list all needed patches that relate to Bugzilla issues, use the option --bugzilla.
To list patches for a specific bug, you can also specify a bug number: --bugzilla=NUMBER. To search for patches relating to multiple Bugzilla issues, add commas between the bug numbers, for example:
zypper list-patches --bugzilla=972197,956917
To list all needed patches that relate to an entry in the CVE database (Common Vulnerabilities and Exposures), use the option --cve.
To list patches for a specific CVE database entry, you can also specify a CVE number: --cve=NUMBER. To search for patches relating to multiple CVE database entries, add commas between the CVE numbers, for example:
zypper list-patches --bugzilla=CVE-2016-2315,CVE-2016-2324
To list all patches regardless of whether they are needed, use the option --all additionally. For example, to list all patches with a CVE number assigned, use:
zypper list-patches --all --cve Issue | No. | Patch | Category | Severity | Status ------+---------------+-------------------+-------------+-----------+---------- cve | CVE-2015-0287 | SUSE-SLE-Module.. | recommended | moderate | needed cve | CVE-2014-3566 | SUSE-SLE-SERVER.. | recommended | moderate | not needed [...]
If a repository contains only new packages, but does not provide patches, zypper patch does not show any effect. To update all installed packages with newer available versions (while maintaining system integrity), use:
sudo zypper update
To update individual packages, specify the package with either the update or install command:
sudo zypper update PACKAGE_NAME sudo zypper install PACKAGE_NAME
A list of all new installable packages can be obtained with the command:
Note that this command only lists packages that match the following criteria:
has the same vendor like the already installed package,
is provided by repositories with at least the same priority than the already installed package,
is installable (all dependencies are satisfied).
A list of all new available packages (regardless whether installable or not) can be obtained with:
sudo zypper list-updates --all
To find out why a new package cannot be installed, use the zypper install or zypper update command as described above.
Whenever you remove a repository from Zypper or upgrade your system, some
packages can get in an
orphaned state. These
orphaned packages belong to no active repository
anymore. The following command gives you a list of these:
sudo zypper packages --orphaned
With this list, you can decide if a package is still needed or can be removed safely.
When patching, updating or removing packages, there may be running processes on the system which continue to use files having been deleted by the update or removal. Use zypper ps to list processes using deleted files. In case the process belongs to a known service, the service name is listed, making it easy to restart the service. By default zypper ps shows a table:
zypper ps PID | PPID | UID | User | Command | Service | Files ------+------+-----+-------+--------------+--------------+------------------- 814 | 1 | 481 | avahi | avahi-daemon | avahi-daemon | /lib64/ld-2.19.s-> | | | | | | /lib64/libdl-2.1-> | | | | | | /lib64/libpthrea-> | | | | | | /lib64/libc-2.19-> [...]
The output format of zypper ps can be controlled as follows:
Create a short table not showing the deleted files.
zypper ps -s PID | PPID | UID | User | Command | Service ------+------+------+---------+--------------+-------------- 814 | 1 | 481 | avahi | avahi-daemon | avahi-daemon 817 | 1 | 0 | root | irqbalance | irqbalance 1567 | 1 | 0 | root | sshd | sshd 1761 | 1 | 0 | root | master | postfix 1764 | 1761 | 51 | postfix | pickup | postfix 1765 | 1761 | 51 | postfix | qmgr | postfix 2031 | 2027 | 1000 | tux | bash |
Show only processes associated with a system service.
PID | PPID | UID | User | Command | Service ------+------+------+---------+--------------+-------------- 814 | 1 | 481 | avahi | avahi-daemon | avahi-daemon 817 | 1 | 0 | root | irqbalance | irqbalance 1567 | 1 | 0 | root | sshd | sshd 1761 | 1 | 0 | root | master | postfix 1764 | 1761 | 51 | postfix | pickup | postfix 1765 | 1761 | 51 | postfix | qmgr | postfix
Only show system services using deleted files.
avahi-daemon irqbalance postfix sshd
Show the commands to retrieve status information for services which might need a restart.
systemctl status avahi-daemon systemctl status irqbalance systemctl status postfix systemctl status sshd
For more information about service handling refer to Section 13.0, The systemd Daemon.
All installation or patch commands of Zypper rely on a list of known repositories. To list all repositories known to the system, use the command:
The result will look similar to the following output:
Example 6-1 Zypper—List of Known Repositories
zypper repos # | Alias | Name | Enabled | Refresh --+--------------+---------------+---------+-------- 1 | SLEHA-12-GEO | SLEHA-12-GEO | Yes | No 2 | SLEHA-12 | SLEHA-12 | Yes | No 3 | SLES12 | SLES12 | Yes | No
When specifying repositories in various commands, an alias, URI or repository number from the zypper repos command output can be used. A repository alias is a short version of the repository name for use in repository handling commands. Note that the repository numbers can change after modifying the list of repositories. The alias will never change by itself.
By default, details such as the URI or the priority of the repository are not displayed. Use the following command to list all details:
zypper repos -d
To add a repository, run
sudo zypper addrepo URI ALIAS
URI can either be an Internet repository, a network resource, a directory or a CD or DVD (see http://en.opensuse.org/openSUSE:Libzypp_URIs for details). The ALIAS is a shorthand and unique identifier of the repository. You can freely choose it, with the only exception that it needs to be unique. Zypper will issue a warning if you specify an alias that is already in use.
zypper enables you to fetch changes in packages from configured repositories. To fetch the changes, run:
sudo zypper refresh
NOTE: Default Behavior of zypper
By default, some commands perform refresh automatically, so you do not need to run the command explicitly.
The refresh command enables you to view changes also in disabled repositories, by using the --plus-content option:
sudo zypper --plus-content refresh
This option fetches changes in repositories, but keeps the disabled repositories in the same state—disabled.
To remove a repository from the list, use the command zypper removerepo together with the alias or number of the repository you want to delete. For example, to remove the repository SLEHA-12-GEO from Example 6-1, use one of the following commands:
sudo zypper removerepo 1 sudo zypper removerepo "SLEHA-12-GEO"
Enable or disable repositories with zypper modifyrepo. You can also alter the repository's properties (such as refreshing behavior, name or priority) with this command. The following command will enable the repository named updates, turn on auto-refresh and set its priority to 20:
sudo zypper modifyrepo -er -p 20 'updates'
Modifying repositories is not limited to a single repository—you can also operate on groups:
To rename a repository alias, use the renamerepo command. The following example changes the alias from Mozilla Firefox to firefox:
sudo zypper renamerepo 'Mozilla Firefox' firefox
Zypper offers various methods to query repositories or packages. To get lists of all products, patterns, packages or patches available, use the following commands:
zypper products zypper patterns zypper packages zypper patches
To query all repositories for certain packages, use search. To get information regarding particular packages, use the info command.
The zypper search command works on package names, or, optionally, on package summaries and descriptions. String wrapped in / are interpreted as regular expressions. By default, the search is not case-sensitive.
zypper search "fire"
zypper search --match-exact "MozillaFirefox"
zypper search -d fire
zypper search -u fire
zypper se "/fir[^e]/"
To search for packages which provide a special capability, use the command what-provides. For example, if you want to know which package provides the Perl module SVN::Core, use the following command:
zypper what-provides 'perl(SVN::Core)'
The what-provides PACKAGE_NAME is similar to rpm -q --whatprovides PACKAGE_NAME, but RPM is only able to query the RPM database (that is the database of all installed packages). Zypper, on the other hand, will tell you about providers of the capability from any repository, not only those that are installed.
To query single packages, use info with an exact package name as an argument. This displays detailed information about a package. In case the package name does not match any package name from repositories, the command outputs detailed information for non-package matches. If you request a specific type (by using the -t option) and the type does not exist, the command outputs other available matches but without detailed information.
If you specify a source package, the command displays binary packages built from the source package. If you specify a binary package, the command outputs the source packages used to build the binary package.
To also show what is required/recommended by the package, use the options --requires and --recommends:
zypper info --requires MozillaFirefox
Zypper now comes with a configuration file, allowing you to permanently change Zypper's behavior (either system-wide or user-specific). For system-wide changes, edit /etc/zypp/zypper.conf. For user-specific changes, edit ~/.zypper.conf. If ~/.zypper.conf does not yet exist, you can use /etc/zypp/zypper.conf as a template: copy it to ~/.zypper.conf and adjust it to your liking. Refer to the comments in the file for help about the available options.
If you have trouble accessing packages from configured repositories (for example, Zypper cannot find a certain package even though you know it exists in one the repositories), refreshing the repositories may help:
sudo zypper refresh
If that does not help, try
sudo zypper refresh -fdb
This forces a complete refresh and rebuild of the database, including a forced download of raw metadata.
If the Btrfs file system is used on the root partition and snapper is installed, Zypper automatically calls snapper when committing changes to the file system to create appropriate file system snapshots. These snapshots can be used to revert any changes made by Zypper. See Section 7.0, System Recovery and Snapshot Management with Snapper for more information.
For more information on managing software from the command line, enter zypper help, zypper help COMMAND or refer to the zypper(8) man page. For a complete and detailed command reference, cheat sheets with the most important commands, and information on how to use Zypper in scripts and applications, refer to http://en.opensuse.org/SDB:Zypper_usage. A list of software changes for the latest SUSE Linux Enterprise Server version can be found at http://en.opensuse.org/openSUSE:Zypper versions.