Linux zypper Command
zypper is a command-line package management tool in the openSUSE and SUSE Linux Enterprise (SLE) distributions, used to manage operations such as installing, updating, removing, and querying software packages. It is the default package manager in these distributions, with functionality similar to apt in Debian/Ubuntu systems or yum/dnf in Red Hat systems.
zypper Basic Syntax
The basic syntax format of the zypper command is as follows:
zypper [全局选项] [命令选项] [参数]
Global Options
--helpor-h: Display help information--versionor-V: Display version information--quietor-q: Quiet mode, reduces output--verboseor-v: Verbose mode, increases output information--no-refresh: Do not refresh software repositories--non-interactiveor-n: Non-interactive mode, automatically answers default questions
Common zypper Commands
Update Software Repositories
zypper refresh
Or abbreviated as:
zypper ref
Install Software Packages
zypper install
Or abbreviated as:
zypper in
Remove Software Packages
zypper remove
Or abbreviated as:
zypper rm
Update System
zypper update
Or abbreviated as:
zypper up
Search Software Packages
zypper search
Or abbreviated as:
zypper se
View Software Package Information
zypper info
Or abbreviated as:
zypper if
List Installed Software Packages
zypper packages --installed-only
Clean Cache
zypper clean
Advanced Usage
Install a Specific Version of a Software Package
zypper install =
Add Software Repository
zypper addrepo
Or abbreviated as:
zypper ar
Remove Software Repository
zypper removerepo
Or abbreviated as:
zypper rr
List All Software Repositories
zypper repos
Or abbreviated as:
zypper lr
Lock 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 install -t pattern devel_basis
Example 2: Search and Install a Text Editor
Example
zypper install vim
Example 3: Update System and Automatically Accept All Licenses
zypper --non-interactive update --auto-agree-with-licenses
Example 4: Add Packman Repository and Install Multimedia Codecs
Example
zypper dup --from packman --allow-vendor-change
zypper install ffmpeg
Common Problem Solutions
1. Dependency Conflicts
When encountering dependency conflicts, you can try:
zypper dup
Or specify allowing vendor changes:
zypper install --allow-vendor-change
2. Locking Software Packages
If you need to prevent a software package from being updated:
zypper addlock
3. Rollback Operations
zypper records all transactions, you can view the history:
zypper history
Then roll back to a specific transaction:
zypper rollback
zypper vs. Other Package Management Tools
| Function | zypper | apt (Debian) | dnf/yum (RHEL) |
|---|---|---|---|
| Update Software Repositories | zypper ref |
apt update |
dnf makecache |
| Install Software Packages | zypper in |
apt install |
dnf install |
| Remove Software Packages | zypper rm |
apt remove |
dnf remove |
| System Update | zypper up |
apt upgrade |
dnf upgrade |
| Search Software Packages | zypper se |
apt search |
dnf search |
| Software Repository Management | zypper ar |
add-apt-repository |
dnf config-manager |
Best Practice Recommendations
-
Regular Updates: Keep the system updated to obtain the latest security patches and feature improvements
Example
zypper refresh
zypper update
-
Use Pattern Installation: openSUSE provides predefined software package combinations (patterns)
zypper install -t pattern
-
Clean Cache: Regularly clean the downloaded software package cache to free up disk space
zypper clean
-
View Changes: Before performing an installation or update, use
--dry-runoption to preview the operations that will be performedzypper install --dry-run
-
Backup Important Data: Before performing major system updates, back up important data
By mastering the zypper command, you can efficiently manage software packages in openSUSE/SLE systems, keeping the system secure and stable. It is recommended that beginners start with basic commands and gradually try more advanced features.
Other Extensions
Linux Command Encyclopedia