Managing Software with Command Line Tools

Contents

7.1. Using Zypper
7.2. RPM—the Package Manager

Abstract

This chapter describes Zypper and RPM, two command line tools for managing software.

Using Zypper

Zypper is a command line tool for installing and updating packages. It is especially useful for accomplishing remote software management tasks or managing software from shell scripts.

zypper has a help overview built in:

zypper help

General Usage

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, run the command without asking anything, decide on your own:

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, apply all needed patches to the system without asking to confirm any licenses—all of them were read in advance:

zypper patch --auto-agree-with-licenses

Some of the commands require one or more arguments:

zypper install mplayer

Some of the 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

Installing and Removing Software with Zypper

To install a package from registered repositories, use:

zypper install package_name

To install a specific version of a package, use:

zypper install package_name=version

zypper also supports wild cards. For example, to install all packages starting with package_name use the following:

zypper install package_name*

You can also install a local or remote RPM directly—Zypper will also install all packages that package_name is dependent on automatically with the following:

zypper install http://www.example.com/package_name.rpm

To remove an installed package, use:

zypper remove package_name

To install and remove packages simultaneously use the +/- or ~/! modifiers:

zypper install emacs -vim

Or:

zypper remove emacs +vim

Or, if you choose to use - with the first package you specify, you must write -- before it to prevent its interpretation as a command option:

zypper install -- -vim emacs
[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 the system may stop working.

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.

If you want to install the corresponding source package of a package, use:

zypper source-install package_name

The following command will also install the build dependencies of the specified package. If you do not want this, add the switch --no-build-deps as follows:

zypper source-install --no-build-deps package_name
  

Of course, this will only work if you have the repository with the source packages added to your repository list. Enter zypper search -t srcpackage to get a list of source packages available in your repositories. For more information about adding repositories, see Section 7.1.4, “Managing Repositories”.

If an error occurs during installation, or anytime you feel the need, verify whether all dependencies are still fulfilled:

zypper verify

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:

zypper patch

In this case, all patches available in your repositories are checked for relevance and installed if necessary. After registering your SUSE Linux Enterprise 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.

If a repository just contains 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, use the update command with arguments:

zypper update package_name

Or the installation command:

zypper install package_name

A list of all new packages available can be obtained with the command:

zypper list-updates

Similarily, to list all needed patches, use:

zypper list-patches

Managing Repositories

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 | 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. Note however that the numbers can change after modifying the list of repositories. The alias will never change by itself.

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 Broadcom Drivers from the example, use the following command:

zypper removerepo 3

To add a repository, run

zypper addrepo URI Alias

URI can either be an Internet repository (see http://en.opensuse.org/Additional_YaST_Package_Repositories for a list of several available repositories), a directory or a CD or DVD. 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. A repository alias can be changed using the renamerepo command. For example, to rename the lengthy SUSE-Linux-Enterprise-Server 11-0 from the example to the short and handy label main, enter:

zypper renamerepo 1 main

Querying

Various querying commands such as search, info or what-provides are available.

search works on package names or, optionally, on package summaries and descriptions, and displays status (S) information in the first column of the list of found packages.

info with a package name as an argument displays detailed information about a package.

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.

For more query commands and detailed usage information, see the Zypper manpage (man zypper).

For More Information

For more information about managing software from the command line, enter zypper help or zypper help command or see the zypper(8) manpage.