I have a few questions about moving from apt-get to zypper in bash scripts.

What is the equivalent of this?

sudo apt-get install curl --assume-yes

(where curl could be any package)

I found the Zypper Cheat Sheet - openSUSE. Very nice! But I would appreciate the voice of experience here -- what's the right way to use zypper in a script where I want to auto agree to all prompts and not skip things that need a response?

With my inexperience I would be tempted to use:

sudo zypper --non-interactive --no-gpg-checks --quiet install --auto-agree-with-licenses curl

But is that really the equivalent of --assume-yes?

What about the equivalent for these?

sudo apt-get autoremove -y
sudo apt-get autoclean -y

This suggests there isn't one...

Is there a replacement for gdebi-core? Or is gdebi not ever needed with zypper's "powerful satisfiability solver"? I use gdebi for situations where I need to install a package on an older version and I have a .deb file already (but not all the dependencies).


zypper is not very consistent with naming flags for subcommands. For install you should use --non-interactive mode, in shortcut -n:

zypper -n install curl

That might be quite confusing for someone coming from apt-get install -y curl. Although zypper's legacy option is -y/--no-confirm (sometimes the only option that actually works).

According to documentation there's no way how to accept a GPG key without interactive mode:

a new key can be trusted or imported in the interactive mode only

Even with --no-gpgp-checks the GPG key will be rejected.

A workaround for scripts is to use pipe and echo:

zypper addrepo http://repo.example.org my_name | echo 'a'

You have the --non-interactive option. From the man page:

Switches  to  non-interactive  mode. 
In this mode zypper doesn't ask user to type answers to various prompts, but uses default answers automatically. 
The  behaviour of this option is somewhat different than that of options like '--yes', since zypper can answer different answers to different questions. 
The answers  also  depend on other options like '--no-gpg-checks'.

There is no real correspondense to apt-get's autoremove. The closest is the --clean-deps option of the remove command, which cleans dependencies right away (but not afterwards).

  • is it possible to add such an option in zypper.conf for permanent confirmation as in other package managers? – user86041 Oct 23 '17 at 16:40
  • I don't know. I haven't used suse in a while, so I can't check it. – mat Oct 26 '17 at 20:57
  • it seems its impossible for zypper unlike pacman, apt, and yum/dnf :-( – user86041 Oct 27 '17 at 15:43

That is a sample

zypper --non-interactive --quiet addrepo --refresh -p 90 http://packman.inode.at/suse/openSUSE_Leap_15.0/ 'packman'
zypper --gpg-auto-import-keys refresh
zypper --non-interactive dist-upgrade --allow-vendor-change --from packman
zypper --non-interactive install vlc vlc-codecs

Of course you can include more options like --auto-agree-with-licenses but remember that makes difference if its before or after install


This worked for me (checked on SLES12SP3):

zypper --non-interactive --quiet ar -C http://myrepo myrepo
zypper --gpg-auto-import-keys ref

Note -C/--no-check for zypper ar.

Now you can install packages:

zypper in -y --auto-agree-with-licenses vim

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.