Package Management With Zypper

 in

As I've mentioned before I'm an openSUSE user, and as long as they don't make the "U" lower case again, I'll probably stick with it. When it comes to package management, OpenSUSE and SUSE Linux Enterprice (and SuSE before them) are usually associated with YaST (and yes, I'm still waiting for them to upper case the "a"). YaST works well but it's a bit verbose for installing a single package, and of course that's just more fodder for the apt-getters with all their apt-get install this and their apt-get install thats. And you can't argue with them, but there are other options with openSUSE: yum and apt4rpm come to mind, but the preferred solution is zypper.

Zypper is a command line tool for package management, it's based on ZYpp, aka libzypp. The WikiPedia entry for Zypp says:

Unlike other common package managers, it provides a powerful satisfiability solver to compute package dependencies and a convenient package management API.

Since we don't want our heads to explode we'll just take it for granted that a powerful satisfiability solver is a good thing.

It turns out that YaST is also (now) based on ZYpp so you don't need to worry that you're missing out on something by using zypper.

Zypper is fairly straightforward to use. If you want to search for a package do zypper search STRING.... The STRING(s) can include * and ? wildcards and there are options for matching all or any of the strings and for full exact matches (the default is a partial match). If you want to search the package descriptions there's an option for that also. For example to search for packages with the word "mail" in the name or in the description do:

$ zypper search --search-descriptions mail
$ # --search-descriptions can be abbreviated as -d
Reading installed packages...

S | Name                 | Summary                                | Type
--+----------------------+----------------------------------------+-----------
  | Buddi                | Buddi - Personal budget software ...   | package
  | CgEddie              | A simple editor with syntax high ...   | package
  | FrostWire            | Gnutella peer-to-peer (P2P) file ...   | package
  ...
i | yast2-mail           | YaST2 - Mail Configuration             | package
  | yast2-mail-plugins   | YaST2-Users/Group Plugins for the ...  | package
  | yum-updatesd         | YUM update notification daemon         | package

When installing packages with zypper, as you'd expect/hope, zypper takes care of installing the package's dependencies:

$ zypper install Buddi
Reading installed packages...

The following NEW packages are going to be installed:
  BrowserLauncher2 swingx Buddi jcommon jfreechart

Overall download size: 4.1 M. After the operation, additional 5.2 M will be used.
Continue? [YES/no]:

Some of the other interesting commands that zypper supports are:

  • refresh - to refresh the package information from the repositories you have defined.
  • addrepo - to add a new repository.
  • remove - to remove a package.
  • list-updates - to list the updates/patches that are available for the packages you have installed.

For a full list of the commands that zypper supports type zypper help and check the man page for more details.

One of Ubuntu's WOW factors seems to be apt-get dist-upgrade, i.e. the ability to upgrade to the next version of Ubuntu (and actually it's a feature of any debian based distro). This is another thing that the apt-getters puff up about, well enter zypper dist-upgrade or zypper dup. This allows you to upgrade from one version of openSUSE to the next. I have not used this feature yet, but posts on the openSUSE wiki seem to indicate that it works well.

So to all you apt-getters out there, all I can say is: zypp it. :

______________________

Mitch Frazier is an Associate Editor for Linux Journal.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi! I'm new to Linux (and

KTP's picture

Hi! I'm new to Linux (and computers in general), but I'm determined to be a Linux Admin. I've only played with OSuSE and Mint. Regarding CLI manager, I find Zypper amazingly simple (I didn't know things could be that simple). I don't know which solves dependencies better, but the syntax of Zypper is really simple compared to Apt. Take a look:

PACKAGES
to install: # zypper in ~
to remove: # zypper rm ~
to search: # zypper se ~
to get info about a package: # zypper if ~

UPDATES
to list available updates of packages: # zypper lu
to update all installed packages: # zypper up

REPOS
to list repositories: # zypper lr
to refresh repos: # zypper ref
to add a repository: # zypper ar (http://~~~)
to remove the fourth repository from the list: # zypper rr 4 (or http://~~~)

And now that I've been playing with Mint, I'm confused with the apt syntax. Why should there be "apt-get install ~", when "apt-cache install ~" doesn't exist. Why not just "apt install ~"??

So, if it's so great...

SheeEttin's picture

So, if it's so great, how can I take it for a spin on Ubuntu? :)

Try this

Mitch Frazier's picture
  apt-get install opensuse

If that doesn't work try different combinations of upper and lower case for "suse" in the package name.

Mitch Frazier is an Associate Editor for Linux Journal.

try zypper moo and you get a

Anonymous's picture

try
zypper moo
and you get a porcupine :D

Thanks

Mitch Frazier's picture

That's nice:

$ zypper moo
   \\\\\
  \\\\\\\__o
__\\\\\\\'/_

Mitch Frazier is an Associate Editor for Linux Journal.

"powerful satisfiability solver"

Anonymous's picture

The "powerful satisfiability solver" is because ZYpp is based on this paper from the University of California, San Diego: http://cseweb.ucsd.edu/~lerner/papers/opium.pdf.

You can see in it that the dependency solver of ZYpp is *perfect* while APT makes errors.

Nice article

Chad McCullough's picture

Very nice article. I'm an apt-getter but I loved the last line, " So to all you apt-getters out there, all I can say is: zypp it." :)

Zypper

Anonymous's picture

Thanks for this article. I first learned apt-get so that is what I'm most comfortable with and never really liked rpm. Zypper looks like it's pretty strait forward. Maybe it's time to give openSuse another try

It's not the same

Anonymous's picture

The apt-get system has years of development. You can't compete with that.

I used ancient RH rpm, medium-ancient RH with up2date, yum enabled distros, etc. My laptop now runs openSUSE with yast and zypper (KDE fan here! Good job in 11.2!).

apt-get/dpkg/deb beats everything by miles. There's package/repository pinning, there's dist-upgrade, debconf with text and GUI frontends for package configuration... I can't even think of everything now.

You can install gnome-desktop with 1 command and remove it with all with 2 commands. And it's easy to use!

Don't get me wrong. I hope zypper gets there soon, but meanwhile it's better to wait, explain how to use and avoid comparing with the "Lion King" :-)

zypper

user5's picture

Maybe you should watch zypper closely. Start here:
http://en.opensuse.org/Zypper/Usage

Zypper is faster, smarter and much more capable than apt or aptitude. These is no doubt about that. Of course you can lock package, set priorities to repositories and dist-upgrade using zypper. And zypper can do this using CLI commands. using Apt you have to edit conf files to use this functions. This is not very usefull.

In addition, zypper SAT solver is much more powerfull, than obsolete solver used in APT. The main difference is, that if any dependency solution exist, zypper will find it. But there are many scenarios where APT fail, even if the solution is obvious.
http://www.mancoosi.org/edos/manager/
http://zorked.net/smart/doc/README.html

Zypper has also ability to work with repositories. You can add, remove, enable or disable repositories withing simple CLI commands. You can set priorities, autorefresh etc... If you are using Apt, you stuck with manual conf file editation. Zypper also install patches and patterns and services. And on top of that, it uses less memory compared to its competitors:

http://duncan.mac-vicar.com/blog/archives/309

So lets have a lokk at syntax now. Apt is a set of tools. You have to remeber all those different apt-get... , apt-cache..., apt-.... tools, which does not seem to be user-friendly design. "Apt install" or "apt search" would be much better syntax. Zypper is a single tool. You always start write "zypper" following a command. If you want to install package in Debian, you just write apt-get install. Zypper does the same using zypper install. But zypper also knows the short syntax using "zypper in". It is much more comfortable to write "zypper XX" where XX are two letters representting action. And watch the nice zypper output when listing packages or repositories. It is fantastic.

Apt and aptitude are great tools and became famous during past years. But zypper is better today, There is now doubt about that.

The Lion King is not a Real Animal

Mitch Frazier's picture

Zypper can install groups of packages also, they're called patterns:

zypper install --type pattern xfce
Reading installed packages...

The following NEW packages are going to be installed:
  xsane xfwm4 xfprint xfce4-volstatus xfce4-session xfce4-panel xfce4-mixer
xfce4-desktop-branding-openSUSE xfce4-desktop xfce4-appfinder xfce-mcs-plugins
xfce-mcs-manager xarchiver thunar-volman thunar orage notification-daemon-xfce
mousepad libxfcegui4 libxfce4util libxfce4mcs gtk-xfce-engine fortune exo Terminal
xfce4-icon-theme

The following NEW patterns are going to be installed:
  yast2_install_wf yast2_basis xfce x11_yast x11_opt x11 sw_management fonts_opt fonts
enhanced_base_opt enhanced_base base apparmor_opt apparmor

Overall download size: 15.4 M. After the operation, additional 46.7 M will be used.
Continue? [YES/no]:

So, let me say it one more time: zypp it. :)

Mitch Frazier is an Associate Editor for Linux Journal.

zypper then is much faster then YAST/YAST2

Bhaskar Chowdhury's picture

Hey guys,

I have been using "zypper" quite some time now. The most noticeable difference I found that (as with every comma nd line app),it(zypper) is much faster then his gui cousin.

Off topic:

"emerge" ,the gentoo package manager is the very best of all breed. Am I biased??? hope certainly not. :)

Thanks
Bhaskar

emerge

user5's picture

From the solver point of view, it is not he best:

http://www.mancoosi.org/edos/manager/

install an older version

geco2's picture

Hiho,

have you ever installed an specific version from one package in a repository?

yum install my-package-0.0.1-0

apt-get install my-package=0.0.1-0

zypp it ^^

zypper in -C (--capability)

HuH?'s picture

zypper in -C (--capability) packagefoo=2.4.0rc3-0.pm.1

Like this?

just `zypper in

Anonymous's picture

just `zypper in foo-2.4.0rc.pmwhatever`. No -C should be needed.

Repo Priorities

Odd-rationale's picture

I love zypper as well. It seems to be almost, if not more, complete package manager than apt.

One very cool feature of zypper the ability to priorities your repos. Priorities allows you to install packages from a preferred repo, even though it is lower in version number. With the openSUSE Build Service, you can end up with a long list of repos. (I'm sure Ubuntu users have a similar issue with PPA's.) Priorities really help keeps things straight.

Funny, that sounds like apt

Sorpigal's picture

Funny, that sounds like apt pinning which has been around in Debian for about a decade.

The fact is that even if the underlying logic is better, which I do not admit, it takes a lot of effort to equal (nevermind surpass!) the deep feature set and utility of apt.

apt

user5's picture

Afaik apt does not know pinning. Using zypper I can call "zypper al " (zypper adlock). How can I lock the package using apt? I'm afraid apt can't do that. You have to open text editor, and pin the package manually in some conf file. Am I right?

One of the biggest advantage of zypper is, that you can do everything using CLI commands.

Not true

Gobuki's picture

Look here for example: http://wiki.ubuntuusers.de/APT-Pinning

And btw being able to use zypper on the cli is no advantage (to apt).

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState