zypper # 显示所有可用的命令可参数
zypper -h [command] # 显示制定命令的帮助信息,例如zypper -h lr
zypper shell/sh # 进入zypper的命令行shell环境
zypper lp # 显示有什么补丁需要被更新
zypper patch # 应用需要的补丁包
zypper se sqlite # 搜索和关键字sqlite有关的软件包
zypper rm sqlite2 # 卸载移除sqlite2软件包
zypper in sqlite3 # 安装sqlite3软件包
zypper in yast* # 安装所有以yast开头的软件包
zypper lr # 查看系统当前的软件源
zypper ref # 刷新软件源
zypper ar # 新增软件源
zypper rr # 删除软件源
zypper nr # 重命名软件源
1、软件仓库管理命令
1)列出当前已经存在的所有软件仓库
#zypper repos or zypper lr
示例(额外显示当前软件仓库的URI及优先级信息):
NTP-slave:/etc/zypp/repos.d # zypper lr -UP
# | Alias | Name | Enabled | Refresh | Priority | URI
--+--------------------------------------------------+--------------------------------------------------+---------+---------+----------+------------------------
1 | SUSE-Linux-Enterprise-Server-11-SP3 11.3.3-1.138 | SUSE-Linux-Enterprise-Server-11-SP3 11.3.3-1.138 | Yes | No | 99 | cd:///?devices=/dev/sr0
2)刷新软件仓库
#zypper refresh or zypper ref
示例(强制更新软件仓库,最后接仓库名称,如果多个,以空格隔开,默认不接则刷新所有仓库):
NTP-slave:/etc/zypp/repos.d # zypper ref -f SUSE-Linux-Enterprise-Server-11-SP3\ 11.3.3-1.138
Forcing raw metadata refresh
Retrieving repository 'SUSE-Linux-Enterprise-Server-11-SP3 11.3.3-1.138' metadata [done]
Forcing building of repository cache
Building repository 'SUSE-Linux-Enterprise-Server-11-SP3 11.3.3-1.138' cache [done]
Specified repositories have been refreshed.
3)修改软件仓库
#zypper modifyrepo or zypper mr
示例(使第一个软件仓库失效即生效,1表示排行第一个的软件仓库,也可以写仓库名称):
NTP-slave:/etc/zypp/repos.d # zypper modifyrepo -d 1
Repository 'SUSE-Linux-Enterprise-Server-11-SP3 11.3.3-1.138' has been successfully disabled.
NTP-slave:/etc/zypp/repos.d # zypper modifyrepo -e 1
Repository 'SUSE-Linux-Enterprise-Server-11-SP3 11.3.3-1.138' has been successfully enabled.
示例(配置仓库为自动刷新(-r)并且使用rpm缓存机制(-k),并修改优先级为70):
NTP-slave:/etc/zypp/repos.d # zypper modifyrepo -rk -p 70 1
Autorefresh has been enabled for repository 'SUSE-Linux-Enterprise-Server-11-SP3 11.3.3-1.138'.
RPM files caching has been enabled for repository 'SUSE-Linux-Enterprise-Server-11-SP3 11.3.3-1.138'.
Repository 'SUSE-Linux-Enterprise-Server-11-SP3 11.3.3-1.138' priority has been set to 70.
The following NEW packages are going to be installed:
apache2 apache2-doc apache2-example-pages apache2-mod_python apache2-prefork apache2-utils libapr-util1 libapr1 mysql mysql-client
The following NEW patterns are going to be installed:
Minimal lamp_server
The following recommended packages were automatically selected:
apache2-doc apache2-example-pages apache2-mod_python apache2-prefork libapr-util1 libapr1 mysql
The following packages need additional customer contract to get support:
mysql mysql-client
10 new packages to install.
Overall download size: 18.1 MiB. After the operation, additional 77.1 MiB will be used.
Continue? [y/n/?] (y):y
Retrieving package apache2-doc-2.2.12-1.38.2.x86_64 (1/10), 1.7 MiB (10.3 MiB unpacked)
Retrieving: apache2-doc-2.2.12-1.38.2.x86_64.rpm [done]
Retrieving package apache2-example-pages-2.2.12-1.38.2.x86_64 (2/10), 62.0
...省略下面的输出...
示例(指定软件仓库进行安装软件,这里的test4为Alias,使用Name不识别):
suse11sp3-1:~ # zypper in test4:vim
Loading repository data...
Reading installed packages...
'vim' is already installed.
No update candidate for 'vim-7.2-8.15.2.x86_64'. The highest available version is already installed.
Resolving package dependencies...
Nothing to do.
示例(在安装的同时,卸载移除软件,注意使用-进行移除不能单独使用,只能在这种情况下使用,因为卸载移除软件使用命令remove)
suse11sp3-1:~ # zypper in vim -gcc-c++
Loading repository data...
Reading installed packages...
'vim' is already installed.
No update candidate for 'vim-7.2-8.15.2.x86_64'. The highest available version is already installed.
Resolving package dependencies...
The following package is going to be REMOVED:
gcc-c++
1 package to remove.
No additional space will be used or freed after the operation.
Continue? [y/n/?] (y): y
Removing gcc-c++-4.3-62.198 [done]
suse11sp3-1:~ #
The following source package is going to be installed:
gcc
.
Overall download size: 9.0 KiB. After the operation, additional 19.0 KiB will be used.
Continue? [y/n/?] (y): y
Media source 'http://www.watchmen.com/sles11sp3' does not contain the desired medium
Abort, retry, ignore? [a/r/i/?] (a): r
Retrieving: gcc-4.3-62.198.src.rpm [error]
File './suse/src/gcc-4.3-62.198.src.rpm' not found on medium 'http://www.watchmen.com/sles11sp3'
Abort, retry, ignore? [a/r/i/?] (a): a
The following NEW package is going to be installed:
dhcp
1 new package to install.
Overall download size: 655.0 KiB. After the operation, additional 1.5 MiB will be used.
Continue? [y/n/?] (y): y
suse11sp3-1:/etc/zypp/repos.d #
6)更新软件包
#zypper update or zypper up
示例(更新所有已安装的软件):
suse11sp3-1:/etc/zypp/repos.d # zypper up
Loading repository data...
Reading installed packages...
Nothing to do.
示例(更新所有以gcc开头的软件包):
suse11sp3-1:/etc/zypp/repos.d # zypper up gcc*
Loading repository data...
Reading installed packages...
No package matching 'gcc*' are installed.
No update candidate for 'gcc43-c++-4.3.4_20091019-0.37.30.x86_64'. The highest available version is already installed.
No package matching 'gcc*' are installed.
No package matching 'gcc*' are installed.
No update candidate for 'gcc-4.3-62.198.x86_64'. The highest available version is already installed.
No package matching 'gcc*' are installed.
No package matching 'gcc*' are installed.
No package matching 'gcc*' are installed.
No update candidate for 'gcc43-4.3.4_20091019-0.37.30.x86_64'. The highest available version is already installed.
No package matching 'gcc*' are installed.
Resolving package dependencies...
Nothing to do.
The following NEW package is going to be installed:
gcc-c++
1 new package to install.
Overall download size: 5.0 KiB. No additional space will be used or freed after the operation.
Continue? [y/n/?] (y): y #这个的y是系统自动输入的,并非人为输入
Installing: gcc-c++-4.3-62.198 [done]
suse11sp3-1:~ # zypper in gcc
2)省略输出信息
#zypper --quiet
示例(安装gcc-c++并且不输出确认之后的标准输出信息):
use11sp3-1:~ # zypper --quiet in gcc-c++
The following NEW package is going to be installed:
gcc-c++
1 new package to install.
Overall download size: 5.0 KiB. No additional space will be used or freed after the operation.
Continue? [y/n/?] (y): y
suse11sp3-1:~ #
S | Name | Summary | Type
--+----------------------+---------------------------------------+-----------
i | gcc | The system GNU C Compiler | package
| gcc | The system GNU C Compiler | srcpackage
| gcc-32bit | The system GNU C Compiler | package
| gcc-c++ | The system GNU C++ Compiler | package
...省略下方输出...
S | Name | Summary | Type
--+---------------------------------+-----------------------------------------------------------------+-----------
i | yast2 | YaST2 - Main Package | package
| yast2 | YaST2 - Main Package | srcpackage
...省略标准输出...
S | Name | Summary | Type
--+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------+-----------
| 32bit | 32-Bit Runtime Environment
...省略输出...
suse11sp3-1:~ # zypper se -r test4/test3/2 | wc -l
4417
S | Name | Summary | Type
--+-----------------+--------------------------------------+--------
i | gcc | The system GNU C Compiler | package
i | gcc43 | The GNU C Compiler and Support Files | package
i | gcc43-c++ | The GNU C++ Compiler | package
i | libgcc43 | C compiler runtime library | package
i | libgcc43-32bit | C compiler runtime library | package
i | libgcc46 | C compiler runtime library | package
i | libgcc46-32bit | C compiler runtime library | package
i | libgcc_s1 | C compiler runtime library | package
i | libgcc_s1-32bit | C compiler runtime library | package
suse11sp3-1:~ #
S | Name | Summary | Type
--+------------------+----------------------------------------+--------
| 32bit | 32-Bit Runtime Environment | pattern
| Basis-Devel | C/C++ Compiler and Tools | pattern
| Dom0 | XEN Virtualization Host (non-embedded) | pattern
| Dom0_KVM | KVM Virtualization Host (non-embedded) | pattern
i | Minimal | Minimal System (Appliances) | pattern
i | WBEM | Web-Based Enterprise Management | pattern
i | apparmor | AppArmor | pattern
i | base | Base System | pattern
| dhcp_dns_server | DHCP and DNS Server | pattern
| directory_server | Directory Server (LDAP) | pattern
i | documentation | Help and Support Documentation | pattern
| file_server | File Server | pattern
| gateway_server | Internet Gateway | pattern
i | gnome | GNOME Desktop Environment | pattern
| kde | KDE Desktop Environment | pattern
| kvm_server | KVM Virtual Machine Host Server | pattern
i | lamp_server | Web and LAMP Server | pattern
| mail_server | Mail and News Server | pattern
| ofed | Infiniband (OFED) | pattern
| oracle_server | Oracle Server Base | pattern
i | print_server | Print Server | pattern
| sap_server | SAP Application Server Base | pattern
i | x11 | X Window System | pattern
| xen_server | Xen Virtual Machine Host Server | pattern
Repository: test3
Name: gcc
Version: 4.3-62.198
Arch: x86_64
Vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
Support Level: Level 3
Installed: Yes
Status: up-to-date
Installed Size: 0 B
Summary: The system GNU C Compiler
Description:
The system GNU C Compiler.
Authors:
--------
The GCC team.
Repository: test3
Name: lamp_server
Version: 11-38.44.33
Arch: x86_64
Vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
Installed: Yes
Summary: Web and LAMP Server
Description:
Software to set up a Web server that is able to serve static, dynamic, and interactive content (like a Web shop). This includes Apache HTTP Server, the database management system MySQL, and scripting languages such as PHP, Python, Ruby on Rails, or Perl.
Contents:
S | Name | Type | Dependency
--+-----------------------+---------+-----------
i | apache2-doc | package |
i | apache2-example-pages | package |
i | apache2-mod_python | package |
i | apache2-prefork | package |
i | libapr-util1 | package |
i | libapr1 | package |
i | apache2 | package |
i | mysql | package |
suse11sp3-1:~ # zypper
3)查询软件包的依赖关系:
#zypper what-provides or zypper wp
示例(查询firefox软件包的依赖关系):
suse11sp3-1:~ # zypper wp firefox
Loading repository data...
Reading installed packages...
S | Name | Type | Version | Arch | Repository
--+----------------+---------+-------------------+--------+-----------
i | MozillaFirefox | package | 17.0.4esr-0.10.42 | x86_64 | test3
suse11sp3-1:~ #
4)查询所有可以获取的软件包
#zypper packages or zypper pa
示例:
NTP-slave:/etc/zypp/repos.d # zypper pa
Loading repository data...
Reading installed packages...
S | Repository | Name | Version | Arch
--+--------------------------------------------------+-------------------------------------+-------------------------------+-------
i | SUSE-Linux-Enterprise-Server-11-SP3 11.3.3-1.138 | 3ddiag | 0.742-32.25 | x86_64
i | wxh | 3ddiag
...省略...
NTP-slave:/etc/zypp/repos.d # zypper pa | wc -l
5728
5、工具命令
1)验证系统所有已安装的软件包的依赖关系是否存在异常
#zypper verify or zypper ve
2)安装新的被推荐的软件包
#zypper install-new-recommends or zypper inr
6、软件包锁命令
1)将软件包上锁
#zypper addlock or zypper al
示例(将已gcc开头的软件包上锁):
suse11sp3-1:~ # zypper al gcc*
Specified lock has been successfully added.
2)将软件包解锁
#zypper removelock or zypper rl
示例(将以gcc开头的软件包解锁):
suse11sp3-1:~ # zypper rl gcc*
1 lock has been successfully removed.
3)查看系统当前的软件包锁
#zypper locks or zypper ll
示例(查看当前系统的所有软件包锁)
suse11sp3-1:~ # zypper ll
# | Name | Type | Repository
--+------+---------+-----------
1 | gcc* | package | (any)
示例:
suse11sp3-1:~ # zypper dup
Warning: You are about to do a distribution upgrade with all enabled repositories. Make sure these repositories are compatible before you continue. See 'man zypper' for more information about this command.
Loading repository data...
Reading installed packages...
Computing distribution upgrade...