Zypper is a command line package manager for installing, updating and
removing packages as well as for managing repositories.
Zypper's syntax is similar to that of rug. In
contrast to rug, Zypper does not require the zmd daemon to run behind the
scenes. For more information about rug compatibility, see man
COMPATIBILITY WITH RUG.
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. 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 type:
Additionally, you can choose from one or more global options by typing them just before the command. For example, --non-interactive means running the command without asking anything (automatically applying the default answers):
zypper --non-interactive patch
To use the options specific to a particular command, type them right after the command. For example, --auto-agree-with-licenses means applying all needed patches to the system without asking to confirm any licenses (they will automatically be accepted):
zypper patch --auto-agree-with-licenses
Some commands require one or more arguments. When using the install command, for example, you need to specify which package(s) to install:
zypper install mplayer
Some options also require an 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 mplayer and amarok packages from the factory repository while being verbose:
zypper -v install --from factory mplayer amarok
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.
zypper remove --dry-run MozillaFirefox
Zypper supports the global --userdata string option for transaction identification purposes. The user-defined string is passed to Zypper history logs in /var/log/zypp/history and Snapper.
zypper --userdata string patch
To install or remove packages use the following commands:
zypper install package_name zypper remove package_name
Zypper knows various ways to address packages for the install and remove commands:
zypper install MozillaFirefox
zypper install MozillaFirefox-3.5.3
zypper install mozilla:MozillaFirefox
Where mozilla is the alias of the repository from which to install.
The following command will install all packages that have names
Moz. Use with care, especially when
zypper install 'Moz*'
For example, if you would like to install a perl module without knowing the name of the package, capabilities come in handy:
zypper install 'perl(Time::ParseDate)'
Together with a capability you can specify an architecture (such as i586 or x86_64) and/or a version. The version must be preceded by an operator: < (lesser than), <= (lesser than or equal), = (equal), >= (greater than or equal), > (greater than).
zypper install 'firefox.x86_64' zypper install 'firefox>=3.5.3' zypper install 'firefox.x86_64>=3.5.3'
You can also specify a local or remote path to a package:
zypper install /tmp/install/MozillaFirefox.rpm zypper install http://download.opensuse.org/repositories/mozilla/SUSE_Factory/x86_64/MozillaFirefox-3.5.3-1.3.x86_64.rpm
To install and remove packages simultaneously use the +/- modifiers. To install emacs and remove vim simultaneously, use:
zypper install emacs -vim
To remove emacs and install vim simultaneously, use:
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 --:
zypper install -emacs +vim # Wrong zypper install vim -emacs # Correct zypper install -- -emacs +vim # same as above zypper remove emacs +vim # same as above
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:
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 in the following:
zypper --non-interactive install package_name
This option allows the use of Zypper in scripts and cron jobs.
WARNING: Do not Remove Mandatory System Packages
Do not remove packages such as glibc, zypper, kernel, or similar packages. These packages are mandatory for the system and, if removed, may cause the system to become unstable or stop working altogether.
If you want to install the corresponding source package of a package, use:
zypper source-install package_name
That command will also install the build dependencies of the specified package. If you do not want this, add the switch -D. To install only the build dependencies use -d.
zypper source-install -D package_name # source package only zypper source-install -d package_name # build dependencies only
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.
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
This command is very useful after plugging in a webcam or WLAN 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 the zypper dist-upgrade command which is discussed in Section 6.1.4, Distribution Upgrade with zypper.
To install all officially released patches applying to your system, just run:
In this case, all patches available in your repositories are checked for relevance and installed, if necessary. After registering your SUSE Linux Enterprise Server installation, an official update repository containing such patches will be added to your system. The above command is all you must enter in order to apply them when needed.
Zypper knows three different commands to query for the availability of patches:
Lists the number of needed patches (patches, that apply to your system but are not yet installed)
~ # zypper patch-check Loading repository data... Reading installed packages... 5 patches needed (1 security patch)
Lists all needed patches (patches, that apply to your system but are not yet installed)
~ # zypper list-patches Loading repository data... Reading installed packages... Repository | Name | Version | Category | Status ------------------------------------+-----------+---------+----------+------- Updates for openSUSE 11.3 11.3-1.82 | lxsession | 2776 | security | needed
Lists all patches available for SUSE Linux Enterprise Server, regardless of whether they are already installed or apply to your installation.
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:
Lists all needed patches for Bugzilla issues. Optionally, you can specify a bug number if you only want to list patches for this specific bug.
Lists all needed patches for CVE (Common Vulnerabilities and Exposures) issues, or only patches matching a certain CVE number, if specified. By default, only unapplied patches are listed. Use -a to list all.
To install a patch for a specific Bugzilla or CVE issue, use the following commands:
zypper patch --bugzilla=number
zypper patch --cve=number
For example, to install a security patch with the CVE number CVE-2010-2713, execute:
zypper patch --cve=CVE-2010-2713
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, use:
To update individual packages, specify the package with either the update or install command:
zypper update package_name zypper install package_name
A list of all new installable packages can be obtained with the command:
Note that this command only packages 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:
zypper list-updates --all
To find out why a new package cannot be installed, just use the zypper install or zypper update command as described above.
To easily upgrade your installation to a new product version (for example, from SUSE Linux Enterprise Server 11 to SUSE Linux Enterprise Server 11 SP1, first adjust your repositories to match the current SUSE Linux Enterprise Server repositories. For details, refer to Section 6.1.5, Managing Repositories with zypper. Then use the zypper dist-upgrade command with the required repositories. This command ensures that all packages will be installed from the repositories currently enabled. For detailed instructions, refer to Section 6.1.4, Distribution Upgrade with zypper.
To restrict the distribution upgrade to packages from a certain repository while considering also the other repositories for satisfying dependencies, use the --from option and specify the repository by either its alias, its number or URI.
NOTE: Differences between zypper update and zypper dist-upgrade
Choose zypper update to update packages to newer versions available for your product version while maintaining system integrity. zypper update will honor the following rules:
When executing zypper dist-upgrade, all packages will be installed from the repositories currently enabled. This rule is enforced, so packages might change vendor or architecture or even might get downgraded. All packages that have unfulfilled dependencies after the upgrade will be uninstalled.
With the zypper command line utility you can upgrade to the next version of the distribution. Most importantly, you can initiate the system upgrade process from within the running system.
This feature is attractive for advanced users who want to run remote upgrades or upgrades on many similarly configured systems.
To avoid unexpected errors during the upgrade process using zypper, minimize risky constellations.
Close as many applications and unneeded services as possible and log out all regular users.
Disable third party repositories before starting the upgrade, or lower the priority of these repositories to make sure packages from the default system repositories will get preference. Enable them again after the upgrade and edit their version string to match the version number of the distribution of the upgraded now running system.
Make sure to have the system registered. f this is not done already, it can either be registered by using the suse_register commandline tool. This will add update sources to the system.module in YaST or by using the
WARNING: Perform Upgrades from Reboot
The upgrade process has to be done completely from beginning to reboot. There is only a limited chance to revert changes. Furthermore, the server has to be connected online during the whole process.
WARNING: Check Your System Backup
Before actually starting the upgrade procedure, check that your system backup is up-to-date and restorable. This is especially important because you must enter many of the following steps manually.
NOTE: Registration Key
If add-ons are installed on your system, you might need to enter your registration key in order to update the system. Be prepared to have the key available.
The program zypper supports long and short command names. For example, you can abbreviate zypper install as zypper in. In the following text, the short variants are used.
Log in as root and perform the following steps:
Refresh all services and repositories:
zypper ref -s
Install any package management updates:
zypper up -t patch
For more information, see Section 1.0, YaST Online Update.
Repeat Step 2 to install all available updates for your system.
Sidenote: If you want o use the above command in a script for an unattended upgrade, use the command:
zypper --non-interactive patch --auto-agree-with-licenses --with-interactive
Read the migration product informations from /etc/products.d/*.prod. The installed products contain information about distribution upgrades and which migration products should be installed to perform the migration. Install them with the following commands:
Extract the product information:
zypper se -t product | grep -h -- "-migration" | cut -d\| -f2
A sample output could be as follows:
Install these migration products (example):
zypper in -t product sle-sdk-SP3-migration SUSE_SLES-SP3-migration
Register the products in order to get the corresponding update repositories:
suse_register -d 2 -L /root/.suse_register.log
WARNING: Enable Additional Repository for SLED Users
Some devel packages have been moved from the SLED11-SP2 installation media to the SLED11-Extras repository. In order to avoid dependency conflicts during upgrade, enable this repository before performing the actual upgrade. Execute yast2 repositories and enable SLED11-Extras there. On SLES this extra step is not needed.
Refresh services and repositores:
zypper ref -s
Check the repositories using zypper lr. If needed, disable the SP1/SP2 Pool/Core/Updates repositories manually and enable the new SP3 (SP3-Pool, SP3-Updates) repositories:
zypper mr --disable REPOALIAS zypper mr --enable REPOALIAS
Perform a dist upgrade by using the following command (example for SLES, adjust catalog names in case SLED is updated):
zypper dup --from SLES11-SP3-Pool --from SLES11-SP3-Updates
You can add more catalogs here if needed, for example, in case addon products are installed. Zypper will report that it will delete the migration product and update the main products. Confirm the message to continue updating the rpm packages.
After the upgrade is finished, register the new products again:
suse_register -d 2 -L /root/.suse_register.log
Reboot the system:
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
# | Alias | Name | Enabled | Refresh --+-----------------------------------+-----------------------------------+---------+-------- 1 | SUSE-Linux-Enterprise-Server 11-0 | SUSE-Linux-Enterprise-Server 11-0 | Yes | No 2 | SLES-11-Updates | SLES 11 Online Updates | Yes | Yes 3 | broadcomdrv | Broadcom Drivers | 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
Sometimes, the list contains a large number of repositories that are not enabled, which might be confusing. To only show enabled repositories, use the following command:
zypper repos -E
WARNING: Possible System Compromise When Adding Repositories with Zypper
By default, digests and signatures of packages from repositories provided by SUSE are
checked to ensure their integrity and origin. This
GPG check is enabled in
the repository configuration file on the server that provides the repository.
When adding a repository with the zypper ar command, this configuration file is downloaded to /etc/zypp/repos.d. Zypper also informs the user about GPG Check option:
GPG check: Yes
Always make sure that the GPG check output is set to
Yes. If set to
No your system can possibly be compromised by, for example, package
downgrades that re-introduce previously fixed vulnerabilities. It is recommended not to
trust repositories where this option is set to
No. In case you are sure that
the GPG check was disabled by mistake, re-enable the option by adding the following line to
the respective repository configuration file in
To add a repository, run
zypper addrepo URIalias
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 is has to be unique. Zypper will issue a warning if you specify an alias that is already in use.
If you want 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 listed as third entry in Example 6-1, use the following command:
zypper removerepo 3
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:
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 just firefox:
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. It works on package names, or, optionally, on package summaries and descriptions. Using the wild cards * and ? with the search term is allowed. By default, the search is not case-sensitive.
zypper search firefox # simple search for "firefox" zypper search "*fire*" # using wild cards zypper search -d fire # also search in package descriptions and summaries zypper search -u firefox # only display packages not already installed
To search for packages which provide a special capability, use the command what-provides. For example, if you would like to know which package provides the perl module SVN::Core, use the following command:
zypper what-provides 'perl(SVN::Core)'
To query single packages, use info with an exact package name as an argument. It displays detailed information about a package. To also show what is required/recommended by the package, use the options --requires and --recommends:
zypper info --requires MozillaFirefox
The what-provides package is similar to rpm -q --whatprovides package, 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.
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 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.
In case you have problems to access packages from configured repositories (for example, Zypper cannot find a certain package though you know that it exists in one the repositories), it can help to refresh the repositories with:
If that does not help, try
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 (via script installed by snapper) when committing changes to the file system to create appropriate file system snapshots. These snapshots can be used for reverting any changes made by zypper. For more information about snapper, see man snapper.
Zypper (and YaST) currently only make snapshots of the root file system. Other subvolumes cannot be configured. This feature is not supported on the default file system.