Abstract
This chapter describes Zypper and RPM, two command line tools for managing software.
Zypper is a command line package manager for installing, updating and removing packages as well as for managing repositories. It is especially useful for accomplishing remote software management tasks or managing software from shell scripts.
For more information on managing software from the command line, enter
zypper help or zypper help
command or see the
zypper(8) manpage. Also see
http://en.opensuse.org/Zypper/Usage for a complete and
detailed command-reference.
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:
zypper patch
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 mplayer and
amarok packages using the
factory repository only, and be verbose:
zypper -v install --repo factory mplayer amarok
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
To install or remove packages use the following commands:
zypper installpackagezypper removepackage
Zypper knows various ways to address packages for the install and remove commands:
zypper in MozillaFirefox
zypper in mozilla:MozillaFirefox
Where mozilla is the alias of the repository from
which to install.
The following command will install all packages that have names starting with “Moz”. Use with care, especially when removing packages.
zypper in Moz*
If you, for example, would like to install a perl module without knowing the name of the package, capabilities come in handy:
zypper in '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 in 'firefox.x86_64' zypper in 'firefox>=3.5.3' zypper in 'firefox.x86_64>=3.5.3'
You can also specify a local or remote path to a package:
zypper in /tmp/install/MozillaFirefox.rpm zypper in 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:
zypper install emacs -vim 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
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-interactiveinstallpackage_name
This option allows the use of Zypper in scripts and cron jobs.
![]() | Do not Remove Mandatory System Packages |
|---|---|
Do not remove packages such as | |
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 -dpackage_name# source package only zypper source-install -Dpackage_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 7.1.4, “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
To verify whether all dependencies are still fulfilled and to repair missing dependencies, use:
zypper verify
In addition to dependencies that must be fulfilled, some packages “recommend” other packages. These recommended packages are only installed if actually available. In case recommended packages were made available after the recommending package has been installed (by adding additional packages), use the following command:
zypper install-new-recommends
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 14.1, “Upgrading the System”.
To install all officially released patches applying to your system, just run:
zypper patch
In this case, all patches available in your repositories are checked for relevance and installed, if necessary. 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-updates Loading repository data... Reading installed packages... S | Repository | Name | Current | Available | Arch --+------------+-------------------------------+---------+------------+------- v | Updates | update-test-interactive | 0-2.35 | 0-9999.1.2 | noarch v | Updates | update-test-optional | 0-2.35 | 0-9999.1.2 | noarch v | Updates | update-test-reboot-needed | 0-2.35 | 0-9999.1.2 | noarch v | Updates | update-test-relogin-suggested | 0-2.35 | 0-9999.1.2 | noarch v | Updates | update-test-security | 0-2.35 | 0-9999.1.2 | noarch
Lists all patches available for openSUSE, regardless of whether they are already installed or apply to your installation.
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:
zypper update
To update individual packages, specify the package with either the update or install command:
zypper updatepackagezypper installpackage
A list of all new packages available can be obtained with the command:
zypper list-updates
![]() | 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:
To upgrade your installation to a new product version use zypper dist-upgrade with the required repositories (see Section 7.1.4, “Managing Repositories with Zypper” for details). This command ensures that 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. | |||||
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:
zypper repos
The result will look similar to the following output:
# | Alias | Name | Enabled | Refresh --+-----------------------+-----------------------+---------+-------- 1 | Updates | Updates | Yes | Yes 2 | openSUSE 11.2-0 | openSUSE 11.2-0 | No | No 3 | openSUSE-11.2-Debug | openSUSE-11.2-Debug | No | Yes 4 | openSUSE-11.2-Non-Oss | openSUSE-11.2-Non-Oss | Yes | Yes 5 | openSUSE-11.2-Oss | openSUSE-11.2-Oss | Yes | Yes 6 | openSUSE-11.2-Source | openSUSE-11.2-Source | No | Yes
When specifying repositories in various commands, an alias, URI or repository number from the zypper repos command output can be used. Note however that the numbers can change after modifying the list of repositories. The alias will never change by itself.
By default, details as the URI or the priority of the repository is not displayed. Use the following command to list all details:
To add a repository, run
zypper addrepoURIAlias
URI can either be an Internet repository, a
network resource, a directory or a CD or DVD (see
http://en.opensuse.org/Libzypp/URI 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. To make working with repositories more
convenient, use short and easy-to-remember aliases.
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. To remove the 3rd entry from the example, 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 name “updates”, turn on auto-refresh and set it's priority to 20:
zypper mr -er -p 20 'updates'
Modifying repositories is not limited to a single repository—you can also operate on groups:
-a: all repositories |
-l: local repositories |
-t: remote repositories |
-m : repositories
of a certain type (TYPE can be one of the
following: http, https, ftp, cd, dvd, dir, file, cifs, smb, nfs, hd, iso) |
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, capabilities or,
optionally, on package summaries and descriptions. Using the wildcards *
and ? with the search term is allowed. By default, the search is not
case-sensitive.
zypper se firefox # simple search for "firefox" zypper se *fire* # using wildcards zypper se -d fire # also search in package descriptions and summaries zypper se -u firefix # only display packages not already installed
To search for packages which provide a special capability, use the
command what-provides. If you, for example, 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. Use the options --requires and
--recommends to also show what is required/recommended
by the package:
zypper info --requires MozillaFirefox
The what-provides
is similar to rpm -q --whatprovides
packagepackage, 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.