Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux zypper command

Linux zypper command

Linux Command Reference Linux Command Reference


zypper is a command-line package management tool in the openSUSE and SUSE Linux Enterprise (SLE) distributions, used to manage operations such as the installation, update, removal, and querying of software packages. It is the default package manager in these distributions, similar to apt in Debian/Ubuntu or yum/dnf in Red Hat systems.


zypper basic syntax

The basic syntax of the zypper command is as follows:

zypper [全局选项]  [命令选项] [参数]

Global options


Common zypper commands

Update software repositories

zypper refresh

or abbreviated as:

zypper ref

Install packages

zypper install 

or abbreviated as:

zypper in 

Remove a package

zypper remove 

or abbreviated as:

zypper rm 

Update the system

zypper update

or abbreviated as:

zypper up

Search for packages

zypper search 

or abbreviated as:

zypper se 

View software package information

zypper info 

or abbreviated as:

zypper if 

List installed packages

zypper packages --installed-only

Clear cache

zypper clean


Advanced usage

Install a specific version of a software package

zypper install =

Add a software repository

zypper addrepo  

or abbreviated as:

zypper ar  

Remove a software repository

zypper removerepo 

or abbreviated as:

zypper rr 

List all software repositories

zypper repos

or abbreviated as:

zypper lr

Lock a software package version

zypper addlock 

View software package dependencies

zypper info --requires 

Verify software package integrity

zypper verify


Practical Application Examples

Example 1: Install development tools

Example

zypper refresh

zypper

install

-t

pattern devel_basis

Example 2: Search for and install a text editor

Example

zypper se editor

zypper

install

vim

Example 3: Update the system and automatically accept all licenses

zypper --non-interactive update --auto-agree-with-licenses

Example 4: Add the Packman repository and install multimedia codecs

Example

zypper

ar

-f

http:

//

ftp.gwdg.de

/

pub

/

linux

/

misc

/

packman

/

suse

/

openSUSE_Leap_15.3

/

packman

zypper dup

--from

packman

--allow-vendor-change

zypper

install

ffmpeg


Common Problem Solutions

1. Dependency Conflicts

When you encounter dependency conflicts, you can try:

zypper dup

Or specify to allow vendor changes:

zypper install --allow-vendor-change 

2. Lock a software package

If you need to prevent a software package from being updated:

zypper addlock 

3. Rollback operations

zypper records all transactions, so you can view the history:

zypper history

Then roll back to a specific transaction:

zypper rollback 


Comparison of zypper with other package management tools

Function zypper apt (Debian) dnf/yum (RHEL)
Update software repositories zypper ref apt update dnf makecache
Install packages zypper in apt install dnf install
Remove a package zypper rm apt remove dnf remove
System updates zypper up apt upgrade dnf upgrade
Search for packages zypper se apt search dnf search
Repository Management zypper ar add-apt-repository dnf config-manager

Best Practice Recommendations

  1. Update regularly: Keep the system updated to get the latest security patches and feature improvements

Example

zypper refresh
zypper update
2.

Install using patterns: openSUSE provides predefined software package groups (patterns)

zypper install -t pattern 
3.

Clear cache: Regularly clean up downloaded package caches to free disk space

zypper clean
4.

View changes: Before performing an installation or update, use --dry-run the option to preview the operations to be performed

zypper install --dry-run 
5.

Back up important data: Back up important data before performing major system updates


By mastering the zypper command, you can efficiently manage software packages in openSUSE/SLE systems and keep the system secure and stable. Beginners are advised to start with basic commands and gradually try more advanced features.


Linux Command Reference Linux Command Reference