3.2 Update from the Command Line with zypper

openSUSE comes with a command line tool for installing and updating packages—zypper. It is especially useful to accomplish remote software management tasks or to manage software from shell scripts.

3.2.1 Installing and Removing Software with Zypper

To install a package from registered installation repositories, use zypper in package_name. To remove an installed package, use zypper rm package_name.

By default, zypper asks for confirmation before installing or removing a selected package. Override this behavior using the --non-interactive option. Note that this option must be given before the actual mode (install, remove, and update) as in zypper --non-interactive in package_name. This option allows the use of zypper in scripts and cron jobs.

3.2.2 Updating Software with Zypper

There are two different ways to update software using zypper. To integrate all officially released patches into your system, just run the zypper up command. In this case, all patches that are available in your installation repositories are checked for relevance, and installed if necessary.

If an installation source just has new packages, but does not provide a patch for this package, zypper up does not show any effect. To update one of these packages, you must reinstall the respective package with the zypper in package_name command.

3.2.3 Managing Installation Repositories

All installation or update commands of zypper rely on a list of installation repositories known to zypper. To list all installation repositories known to the system, use the command zypper sl.

If you want to remove an installation repository, first list all the repositories and then use the command zypper sd #number. For example, the installation repository you want to remove could be represented by the following line (line break added for layout reasons):

2 | No | Yes | YaST | openSUSE FACTORY Extra 10.3 | \
http://download.opensuse.org/distribution/SL-Factory-non-oss/inst-source-extra/

In this case run the command zypper sd 2 to remove this installation repository from the list.

To add an installation repository, you can use the command zypper sa installation_repository. Information about additional installation sources is provided at http://en.opensuse.org/Installation_Sources.

3.2.4 Using the Zypper Shell

Sometimes, several different zypper commands must be run in a sequence. To prevent zypper from rereading all the databases for each zypper command, it is possible to run zypper in shell mode: zypper sh.

When the shell is running, just issue the zypper commands with the respective parameters:

zypper sh
zypper> in zsh
...
zypper> exit

Using the zypper shell is usually faster, because all the relevant data stays in memory.

Zypper supports the readline library. This means that you can use all the command line editing functions in the zypper shell that are also available in the Bash shell. Zypper maintains its command history in file ~/.zypper_history.

3.2.5 For More Information

For more information about updating from the command line, enter zypper --help or see the zypper(8) man page. For examples and detailed information, visit http://en.opensuse.org/Using_zypper.