Linux Basics: Zypper Usage On openSUSE

As you may know already, Zypper is most powerful command line package manager for installing, updating and removing packages as well as for managing repositories. Zypper is an open source project sponsored by Novell, and licensed under GNU GPL v2. It has been used in openSUSE since version 10.2.

Unlike other popular package managers such as APT and YUM, Zypper uses the SAT solver, which is the best available dependency solution. In my personal experience, I never ever got a dependency problem while using Zypper. If you encounter with any dependency problems, Zypper will present you multiple choices to resolve them wisely. So you never end up with any dependency problems, and it displays the output more informative in a tabular format.

One more notable feature of Zypper is it has the best syntax format. You can use commands either in full or short format.

For example, you can install VLC package using zypper in two methods.

Method 1:

# zypper install vlc

Method 2:

Also, you can use the above command in a short format as shown below.

# zypper in vlc

Here I used “in” instead of “install”.

To update system, you can use “zypper up” instead of “zypper update”.

Likewise, Almost all commands have such a shortcut.

Zypper Usage

Now, let us see some practical examples of zypper usage.

The syntax of Zypper is:

# zypper [global-options]command[command-options][arguments] ...

The components enclosed in brackets are not mandatory.

Installing Packages

Zypper usage is simple and straight forward. To install a package, enter the following command:

# zypper install <package-name>

Or

# zypper in <package-name>

Example:

# zypper in vlc

Sample output:

Enter “y” to continue installation. If you want to continue the installation without asking anything, use “–non-interactive” global option just before command. Zypper will not ask you any confirmation from you, and will install the packages by automatically by applying the default answers.

# zypper --non-interactive in vlc

Or

# zypper -n in vlc

The above command will install VLC package without asking anything from you by accepting the default answers.

We can use wildcards with zypper command to install packages starting with particular letters. For example, to install packages starting with letters “abc“, use the following command:

# zypperinstall 'abc*'

If you want to install the source package of a particular package, enter the following command:

# zypper source-install vlc

The above command will install the source package of vlc along with build dependencies.

If you do not want this, use -D option.

# zypper source-install -D vlc

To install only the build dependencies, use -d option.

# zypper source-install -d vlc

Removing packages

To remove a package, use either one of the following commands:

# zypper remove vlc

Or

# zypper -n remove vlc

Installing and removing packages simultaneously

Wouldn’t be better, if it possible to install and remove packages simultaneously? Yes, you can do this using +/- modifiers.

For example, To install mplayer and remove vlc simultaneously, enter the following command:

# zypper install mplayer -vlc

Just like above, you remove mplayer and install vlc simultaneously as shown below.

# zypper remove mplayer +vlc

Searching packages

To search a particular package, use the following command:

# zypper -n search vlc

Or

# zypper -n se vlc

Sample output:

Installing Patches and Patterns

To install all officially released patches to your system, run the following command:

Retrieving repository 'VLC' metadata -----------------------------------------------------------------------------------------------------------------------[\]
New repository or package signing key received:
Key ID: 33DE8FB7C8DA93D2
Key Name: Dominique Leuenberger (VLC openSUSE Repository) <[email protected]>
Key Fingerprint: BC8D780DE3308581B2E0708533DE8FB7C8DA93D2
Key Created: Monday 07 November 2011 03:33:13 PM IST
Key Expires: Wednesday 06 November 2013 03:33:13 PM IST (EXPIRED)
Repository: VLC
Do you want to reject the key, trust temporarily, or trust always? [r/t/a/?] (r): a
Retrieving repository 'VLC' metadata ....................................................................................................................[done]
Building repository 'VLC' cache .........................................................................................................................[done]
Repository 'openSUSE BuildService - Database' is up to date.
Repository 'openSUSE BuildService - PHP' is up to date.
Repository 'Packman Repository' is up to date.
Repository 'openSUSE-13.1-Debug' is up to date.
Repository 'openSUSE-13.1-Update-Debug' is up to date.
Repository 'openSUSE-13.1-Update-Debug-Non-Oss' is up to date.
Repository 'openSUSE-13.1-Oss' is up to date.
Repository 'openSUSE-13.1-Source' is up to date.
Repository 'openSUSE-13.1-Update' is up to date.
Repository 'openSUSE-13.1-Update-Non-Oss' is up to date.
All repositories have been refreshed.

The alias is a shorthand and unique identifier of the repository. You can choose the alias name as per your liking, 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 see, if VLC repository is added successfully, enter the following command:

POPULAR CATEGORY

Unixmen provide Linux Howtos, Tutorials, Tips & Tricks ,Opensource News. It cover most popular distros like Ubuntu, LinuxMint, Fedora, Centos. It is your Gate to the the world of Linux/Unix and Opensource in General.