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 zypper, section 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 amarokpackages 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
6.1.2Installing and Removing Software with Zypper
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:
by the exact package name (and version number)
zypper install MozillaFirefox
zypper install MozillaFirefox-3.5.3
by repository alias and package name
zypper install mozilla:MozillaFirefox
Where mozilla is the alias of the repository from which to install.
by package name using wild cards
The following command will install all packages that have names starting with Moz. Use with care, especially when removing packages.
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)'
by capability and/or architecture and/or version
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'
by path to the RPM file
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 vimsimultaneously, 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.
Installing or Downloading Source Packages
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 –directoryoption. To only show missing or extraneous packages without downloading or deleting anything, use the –statusoption. To delete extraneous source packages, use the –delete option. To disable deleting, use the –no-deleteoption.
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 command:
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.
6.1.3Updating Software with Zypper
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