sudoedit.com!

Managing packages with zypper

sudoedit.com!

Suse Enterprise Linux and it's upstream community distro openSUSE use a package manager called zypper.

zypper is a fast easy to use package management tool. In my opinion, zypper is hands down the best package manager out there. It provides meaningful, easy to read output, it resolves package dependencies quickly, and it has a cool name.

zypper has many options that can be abbreviated; install (in), search (se), info (if), update (up) and lots of others.

Basic package operations

Search for a package

Search with zypper search or zypper se.

luke@OpenSUSE-tst:~> sudo zypper search apache2
Loading repository data...
Reading installed packages...
S | Name                       | Summary                                                              | Type   
--+----------------------------+----------------------------------------------------------------------+--------
| apache2                    | The Apache Web Server Version 2.4                                    | package
| apache2-devel              | Apache 2 Header and Include Files                                    | package
| apache2-doc                | Additional Package Documentation                                     | package
| apache2-example-pages      | Example Pages for the Apache 2 Web Server                            | package
| apache2-icons-oxygen       | Oxygen icons for Apache 2                                            | package
| apache2-mod_apparmor       | AppArmor module for apache2                                          | package
| apache2-mod_auth_kerb      | Kerberos Module for Apache                                           | package
| apache2-mod_authn_otp      | Apache module for one-time password authentication                   | package
| apache2-mod_dnssd          | Apache2 module for Zeroconf support via DNS-SD                       | package
| apache2-mod_evasive        | Denial of Service evasion module for Apache                          | package
| apache2-mod_fastcgi        | A FastCGI Module for Apache 2                                        | package
| apache2-mod_fcgid          | Alternative FastCGI module for Apache2                               | package
| apache2-mod_jk             | Connectors between Apache and Tomcat Servlet Container               | package
| apache2-mod_mono           | Run ASP.NET Pages on Unix with Apache and Mono                       | package
| apache2-mod_nss            | SSL/TLS module for the Apache HTTP server                            | package
| apache2-mod_perl           | Embedded Perl for Apache                                             | package
| apache2-mod_perl-devel     | Embedded Perl for Apache - Development package                       | package
| apache2-mod_php5           | PHP5 Module for Apache 2.0   
| apache2-mod_php7           | PHP7 Module for Apache 2.0                                           | package
| apache2-mod_proxy_uwsgi    | uWSGI Proxy Module for Apache 2.0                                    | package
| apache2-mod_python         | A Python Module for the Apache 2 Web Server                          | package
| apache2-mod_scgi           | Apache module named mod_scgi that implements the client side of th-> | package
| apache2-mod_security2      | ModSecurity Open Source Web Application Firewall                     | package
| apache2-mod_tidy           | Apache Module using the Tidy Library to Clean Up HTML, XHTML, and -> | package
| apache2-mod_uwsgi          | uWSGI Module for Apache 2.0                                          | package
| apache2-mod_wsgi           | Python WSGI adapter module for Apache                                | package
| apache2-mod_wsgi-python3   | A WSGI interface for Python3 web applications in Apache              | package
| apache2-prefork            | Apache 2 "prefork" MPM (Multi-Processing Module)                     | package
| apache2-utils              | Apache 2 utilities                                                   | package
| apache2-worker             | Apache 2 worker MPM (Multi-Processing Module)                        | package
| perl-Apache2-AuthCookieDBI | An AuthCookie module backed by a DBI database.                       | package

As you can see the output is clean and includes a short summary of each matching item in the search.

Get information about a package

Use zypper info or zypper if.

luke@OpenSUSE-tst:~> zypper info apache2
Loading repository data...
Reading installed packages...
Information for package apache2:
--------------------------------
Repository     : Main Repository (OSS)  
Name           : apache2    
Version        : 2.4.23-4.3           
Arch           : x86_64
Vendor         : openSUSE
Installed Size : 4.0 MiB  
Installed      : No
Status         : not installed
Summary        : The Apache Web Server Version 2.4
Description    :
This version of httpd is a major release of the 2.4 stable branch, and represents the best available version of Apache HTTP Server. New features include Loadable MPMs, major improvements to OCSP support, mod_lua, Dynamic Reverse Proxy configuration, Improved Authentication/Authorization, FastCGI Proxy, New Expression Parser, and a Small Object Caching API. See /usr/share/doc/packages/apache2/, http://httpd.apache.org/, and http://httpd.apache.org/docs-2.4/upgrading.html.

The info option will show you which repository the package is in, its name, version, whether or not it is installed, and a brief description.

Install a package

To install a package type zypper install package_name or zypper in package_name

luke@OpenSUSE-tst:~> sudo zypper in apache2
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 6 NEW packages are going to be installed:  apache2 apache2-prefork apache2-utils libapr1 libapr-util1 libnghttp2-14

6 new packages to install.
Overall download size: 1.8 MiB. Already cached: 0 B. After the operation, additional 5.4 MiB will be used.

Continue? [y/n/? shows all options] (y):

Running the install option solves for all dependencies quickly, and display's them in a way that allows an administrator to easily see everything that will be installed and how much disk space will be consumed. In this case we see 6 new packages.

Check for updates

Check for updates with zypper list-updates or zypper lu.

luke@OpenSUSE-tst:~> zypper lu
Loading repository data...
Reading installed packages...
S | Repository             | Name                        | Current Version | Available Version       | Arch  
--+------------------------+-----------------------------+-----------------+-------------------------+-------
v | Main Update Repository | ImageMagick                 | 6.8.8.1-20.1    | 6.8.8.1-22.2            | x86_64
v | Main Update Repository | alsa                        | 1.1.2-1.2       | 1.1.2-3.1               | x86_64
v | Main Update Repository | autoyast2-installation      | 3.1.151-1.2     | 3.1.154-3.1             | noarch
v | Main Update Repository | dolphin                     | 16.08.2-1.1     | 16.08.2-3.1             | x86_64
v | Main Update Repository | dolphin-part                | 16.08.2-1.1     | 16.08.2-3.1             | x86_64
v | Main Update Repository | ispell                      | 3.3.02-111.4    | 3.3.02-113.1            | x86_64
v | Main Update Repository | ispell-american             | 3.3.02-111.4    | 3.3.02-113.1            | x86_64
v | Main Update Repository | java-1_7_0-openjdk          | 1.7.0.111-35.1  | 1.7.0.121-37.2          | x86_64
v | Main Update Repository | java-1_7_0-openjdk-headless | 1.7.0.111-35.1  | 1.7.0.121-37.2          | x86_64
v | Main Update Repository | k3b                         | 2.0.3-6.21      | 2.0.3-9.1               | x86_64
v | Main Update Repository | k3b-lang                    | 2.0.3-6.21      | 2.0.3-9.1               | noarch
v | Main Update Repository | kernel-default              | 4.4.36-5.1      | 4.4.36-8.1              | x86_64
v | Main Update Repository | libMagickCore-6_Q16-1       | 6.8.8.1-20.1    | 6.8.8.1-22.2            | x86_64
v | Main Update Repository | libMagickWand-6_Q16-1       | 6.8.8.1-20.1    | 6.8.8.1-22.2            | x86_64
v | Main Update Repository | libasound2                  | 1.1.2-1.2       | 1.1.2-3.1               | x86_64
v | Main Update Repository | libblkid1                   | 2.28-5.10       | 2.28-7.1                | x86_64
v | Main Update Repository | libdolphinvcs5              | 16.08.2-1.1     | 16.08.2-3.1             | x86_64
v | Main Update Repository | libfdisk1                   | 2.28-5.10       | 2.28-7.1                | x86_64
v | Main Update Repository | libgc1                      | 7.2d-6.4        | 7.2d-8.1                | x86_64
v | Main Update Repository | libgit2-24                  | 0.24.1-1.16     | 0.24.1-3.1              | x86_64
v | Main Update Repository | libmount1                   | 2.28-5.10       | 2.28-7.1                | x86_64
v | Main Update Repository | libpcre1                    | 8.33-4.51       | 8.39-6.1                | x86_64
v | Main Update Repository | libpcre1-32bit              | 8.33-4.51       | 8.39-6.1                | x86_64
v | Main Update Repository | libpcre16-0                 | 8.33-4.51       | 8.39-6.1                | x86_64
v | Main Update Repository | libsensors4                 | 3.4.0-2.4       | 3.4.0-4.1               | x86_64
v | Main Update Repository | libsmartcols1               | 2.28-5.10       | 2.28-7.1                | x86_64
v | Main Update Repository | libsystemd0                 | 228-13.1        | 228-15.1                | x86_64
v | Main Update Repository | libsystemd0-32bit           | 228-13.1        | 228-15.1                | x86_64
v | Main Update Repository | libudev1                    | 228-13.1        | 228-15.1                | x86_64
v | Main Update Repository | libuuid1                    | 2.28-5.10       | 2.28-7.1                | x86_64
v | Main Update Repository | libwicked-0-6               | 0.6.38-2.1      | 0.6.39-4.1              | x86_64
v | Main Update Repository | systemd                     | 228-13.1        | 228-15.1                | x86_64
v | Main Update Repository | systemd-32bit               | 228-13.1        | 228-15.1                | x86_64
v | Main Update Repository | systemd-bash-completion     | 228-13.1        | 228-15.1                | noarch
v | Main Update Repository | systemd-logger              | 228-13.1        | 228-15.1                | x86_64
v | Main Update Repository | systemd-sysvinit            | 228-13.1        | 228-15.1                | x86_64
v | Main Update Repository | udev                        | 228-13.1        | 228-15.1                | x86_64
v | Main Update Repository | util-linux                  | 2.28-5.10       | 2.28-7.1                | x86_64
v | Main Update Repository | util-linux-lang             | 2.28-5.10       | 2.28-7.1                | noarch
v | Main Update Repository | util-linux-systemd          | 2.28-5.2        | 2.28-7.1                | x86_64
v | Main Update Repository | w3m                         | 0.5.3-158.2     | 0.5.3.git20161120-160.1 | x86_64
v | Main Update Repository | wicked                      | 0.6.38-2.1      | 0.6.39-4.1              | x86_64
v | Main Update Repository | wicked-service              | 0.6.38-2.1      | 0.6.39-4.1              | x86_64
v | Main Update Repository | xdm                         | 1.1.11-11.1     | 1.1.11-13.1             | x86_64
v | Main Update Repository | xdm-xsession                | 1.1.11-11.1     | 1.1.11-13.1             | x86_64
v | Main Update Repository | yast2-services-manager      | 3.1.42-16.1     | 3.1.43-18.1             | noarch

List updates presents a table that shows which repository an update will come from, which packages have an update, the current version, and the latest available version.

Update with zypper

Update the system with zypper update or zypper up.

luke@OpenSUSE-tst:~> sudo zypper up
Loading repository data...
Reading installed packages...
The following NEW package is going to be installed:
kernel-default-4.4.36-8.1
The following application is going to be REMOVED:
Dolphin
The following 45 packages are going to be upgraded:
alsa autoyast2-installation dolphin dolphin-part ImageMagick ispell ispell-american java-1_7_0-openjdk
java-1_7_0-openjdk-headless k3b k3b-lang libasound2 libblkid1 libdolphinvcs5 libfdisk1 libgc1 libgit2-24
libMagickCore-6_Q16-1 libMagickWand-6_Q16-1 libmount1 libpcre1 libpcre1-32bit libpcre16-0 libsensors4 libsmartcols1 libsystemd0 libsystemd0-32bit libudev1 libuuid1 libwicked-0-6 systemd systemd-32bit systemd-bash-completion systemd-logger systemd-sysvinit udev util-linux util-linux-lang util-linux-systemd w3m wicked wicked-service xdm xdm-xsession yast2-services-manager

45 packages to upgrade, 1 new.
Overall download size: 121.1 MiB. Already cached: 0 B. After the operation, additional 237.9 MiB will be used.

Continue? [y/n/? shows all options] (y):

Once again you see each package that is to be updated along with disk usage.

After the update has completed use zypper ps to show which processes, if any, need to be restarted. In this case, we updated the kernel so it's a good idea to do a full reboot.

List installed packages

To get a list of all installed packages try running

sudo zypper se -i

Find patterns

Suse uses the term patterns to describe groups of packages that are commonly installed together. For instance a mail server will have an email service, maybe an antivirus scanner, a spam blocker...

Try sudo zypper patterns to get a list of installable patterns.

More info

For further reading, you can always check the man pages man zypper or check out Suse documentation here: https://documentation.suse.com/sled/15-SP1/html/SLED-all/cha-sw-cl.html#sec-zypper


#Linux #openSUSE #zypper