suse-zypper常用命令大全及软件仓库配置

时间:2022-12-10 08:51:31

博文说明【前言】:

    本文将通过个人口吻详细的介绍在SUSE系统下的zypper相关配置命令,如想快速实现软件仓库的配置,可以直接拉到文章末尾第二部分,我将配置命令挑出来进行了总结。

    在目前时间点【2017年6月9号】下,所掌握的技术水平有限,可能会存在不少知识理解不够深入或全面,望大家指出问题共同交流,在后续工作及学习中如发现本文内容与实际情况有所偏差,将会完善该博文内容。

参考文献及技术网站链接:
1、https://en.opensuse.org/SDB:Zypper_usage 
suse的官方网站,本文大部分内容基本上都参考这个网站
2、https://en.opensuse.org/openSUSE:Libzypp_URIs
zypper配置文件中的软件仓库的书写格式大全



正文:

    Zypper是SUSE Linux中基于Libzypp的用于安装,升级,卸载,管理仓库、进行各种包查询的命令行接口,类似RHEL及Centos中yum,功能十分强大。


1、zypper常用命令

快速参考
以下命令可能是你经常使用的.

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.

示例(配置对远程remote仓库使用cache缓存机制):
NTP-slave:/etc/zypp/repos.d # zypper modifyrepo -kt


4)新增软件仓库
#zypper addrepo or zypper ar

示例(新增软件仓库,已经事先在另一台服务器上传镜像并安装httpd服务,在网页目录下创建对应目录,并将镜像挂载到这个目录,注意需要在hosts文件添加IP到域名的映射关系):
suse11sp3-1:~ # zypper addrepo http://www.watchmen.com/sles11sp3 test1
Adding repository 'test1' [done]
Repository 'test1' successfully added
Enabled: Yes
Autorefresh: No
GPG check: Yes
URI: http://www.watchmen.com/sles11sp3

【注意】:执行新增软件仓库命令之后,会在对应目录下生成repo文件,以本例为例,执行之后再/etc/zypp/repos.d目录下生成test1.repo,文件内容如下:
suse11sp3-1:/etc/zypp/repos.d # cat test1.repo 
[test1]                #方框内的内容对应ALIAS,后续可以使用nr命令在命令行修改
name=test1            #这里的内容对应NAME,后续不能在命令行修改
enabled=1
autorefresh=0
baseurl=http://www.watchmen.com/sles11sp3
type=NONE

其实这也就是说我们可以手动创建编辑这个文件,然后刷新软件仓库进行生效。

5)删除软件仓库
#zypper removerepo or zypper rr

示例(删除上例中新增的软件仓库):
suse11sp3-1:~ # zypper removerepo test1
Removing repository 'test1' [done]
Repository 'test1' has been removed.

6)重命名软件仓库
#zypper namerepo or zypper nr

示例(将软件仓库对应的ALIAS进行重命名,注意这个只对别名生效,不会修改NAME):
suse11sp3-1:~ # zypper lr
# | Alias                                            | Name                                             | Enabled | Refresh
--+--------------------------------------------------+--------------------------------------------------+---------+--------
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     
2 | test1                                            | test1                                            | Yes     | No     
suse11sp3-1:~ # zypper renamerepo test1 wxh
Repository 'test1' renamed to 'wxh'.
suse11sp3-1:~ # zypper lr
# | Alias                                            | Name                                             | Enabled | Refresh
--+--------------------------------------------------+--------------------------------------------------+---------+--------
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     
2 | wxh                                              | test1                                            | Yes     | No     
 
suse11sp3-1:~ # zypper nr 2  test2
Repository 'wxh' renamed to 'test2'.
注意:这里的要修改的别名也可以使用对应的编号进行代替,每个软件仓库都有一个编号


2、软件包管理命令

1)安装软件包
#zypper install or zypper in 

示例(安装有关yast的所有软件包及相关模块):
suse11sp3-1:~ # zypper in yast*

示例(安装LAMP环境需要的所有软件包,使用-t指定安装类型,这里类型为pattern(模式),默认类型为软件包package):
suse11sp3-1:~ # zypper in -t pattern lamp_server 
Loading repository data...
Reading installed packages...
Resolving package dependencies...

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:~ #

2)卸载移除软件包
#zypper remove or zypper rm

示例(卸载移除gcc-c++软件包):
suse11sp3-1:~ # zypper rm gcc-c++
Loading repository data...
Reading installed packages...
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]

3)安装源码包类型的软件(srcpackage)
# zypper source-install or zypper si or zypper in -t srcpackage

示例:
suse11sp3-1:/etc/zypp/repos.d # zypper si gcc
Reading installed packages...
Loading repository data...
Resolving package dependencies...

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

注意:可以看到没有获取到对应的资源,实际上镜像中连src这个目录都没有。

4)只下载所需的软件包,但是不安装
#zypper in -d 

示例(下载gcc-c++软件包):
suse11sp3-1:/etc/zypp/repos.d # zypper in -d gcc-c++
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
  gcc-c++ 

1 new package to install.
Overall download size: 5.0 KiB. Download only.
Continue? [y/n/?] (y): y
Retrieving package gcc-c++-4.3-62.198.x86_64 (1/1), 5.0 KiB (0 B unpacked)
Retrieving: gcc-c++-4.3-62.198.x86_64.rpm [done]

suse11sp3-1:/etc/zypp/repos.d # find / -name gcc-c++-4.3-62.198.x86_64.rpm
/var/cache/zypp/packages/test4/suse/x86_64/gcc-c++-4.3-62.198.x86_64.rpm
我们可以在系统上找到已经下载的软件包

5)只显示安装软件具体需要安装那些依赖软件,并不实际安装
#zypper in -D

示例(显示安装dhcp涉及到那些软件包):
suse11sp3-1:/etc/zypp/repos.d # zypper in -D dhcp 
Loading repository data...
Reading installed packages...
Resolving package dependencies...

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.

3、Zypper脚本及应用程序

1)使用的zypper的非交互模式
#zypper --non-interactive

示例(安装gcc-c++,并跳过需要手动输入的交互信息,其实是替你输入了确认信息):
suse11sp3-1:~ # zypper --non-interactive  in gcc-c++
Loading repository data...
Reading installed packages...
Resolving package dependencies...

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:~ # 


4、查询命令

1)查询软件包
#zypper search or zypper se

示例(在包摘要信息和描述(-d)中查询匹配gcc(--match-words)关键字的软件包,并区分大小写(-C)):
suse11sp3-1:~ # zypper se -dC --match-words gcc
Loading repository data...
Reading installed packages...

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   
...省略下方输出...


示例(查询所有以yast开头的软件包):
suse11sp3-1:~ # zypper se yast*
Loading repository data...
Reading installed packages...

S | Name                            | Summary                                                         | Type      
--+---------------------------------+-----------------------------------------------------------------+-----------
i | yast2                           | YaST2 - Main Package                                            | package   
  | yast2                           | YaST2 - Main Package                                            | srcpackage
...省略标准输出...


示例(查询指定某个软件仓库的所有软件包,注意在这里写ALIAS、NAME、仓库编号都可以):
suse11sp3-1:~ # zypper se -r test4
Loading repository data...
Reading installed packages...

S | Name                                | Summary                                                                                                                 | Type      
--+-------------------------------------+-------------------------------------------------------------------------------------------------------------------------+-----------
  | 32bit                               | 32-Bit Runtime Environment                                                                                              
...省略输出...

suse11sp3-1:~ # zypper se -r test4/test3/2 | wc -l 
4417

示例(查询所有包含gcc关键字并且是已安装(-i)的软件包)
suse11sp3-1:~ # zypper se -i *gcc*
Loading repository data...
Reading installed packages...

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:~ # 

示例(在指定仓库下查询所有可获取的已安装和未安装的类型为模式的软件包组件)
suse11sp3-1:~ # zypper se -t pattern -r test4
Loading repository data...
Reading installed packages...

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


2)查询软件包详细信息
#zypper info or zypper if

示例(查询gcc软件包的详细信息):
suse11sp3-1:~ # zypper info  gcc
Loading repository data...
Reading installed packages...

Information for package gcc:

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.

示例(查询类型的pattern模式的lamp_server软件包的详细信息):
suse11sp3-1:~ # zypper if -t pattern lamp_server
Loading repository data...
Reading installed packages...

Information for pattern lamp_server:

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)     


7、更新及补丁管理命令

1)列出被需要的补丁包
#zypper list-patches or zypper lp 

示例:
suse11sp3-1:~ # zypper lp
Loading repository data...
Reading installed packages...
No updates found.

2)应用补丁包
#zypper patch

示例:
suse11sp3-1:~ # zypper patch
Loading repository data...
Reading installed packages...
Resolving package dependencies...

Nothing to do.

3)列出所有可以得到补丁包
#zypper patches

示例:
suse11sp3-1:~ # zypper patches
Loading repository data...
Reading installed packages...
No needed patches found.

4)检验补丁包
#zypper patch-check or zypper pchk

示例:
suse11sp3-1:~ # zypper pchk
Loading repository data...
Reading installed packages...
0 patches needed (0 security patches)

5)获取补丁包信息
#zypper patch-info or zypper info -t patch 

示例:
suse11sp3-1:~ # zypper patch-info [补丁包名称]
Required argument missing.
Usage:
patch-info <patchname> ...

Show detailed information for patches.

This is a rug compatibility alias for 'zypper info -t patch'.

6)列出所有可用的软件包更新
#zypper list-updates or zypper lu

示例:
suse11sp3-1:~ # zypper lu
Loading repository data...
Reading installed packages...
No updates found.

7)升级软件包更新
#zypper update or zypper up 

示例:
suse11sp3-1:~ # zypper up
Loading repository data...
Reading installed packages...

Nothing to do.


8、操作系统版本更新命令

#zypper dist-upgrade or zypper dup

示例:
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...

Nothing to do.

注意:使用这个命令可以根据已经挂载的软件源进行系统版本的升级,需要注意的时候请千万要指定正确的软件源,可以使用--repo参数指定具体版本对应的软件仓库


9、相关知识点

1)软件仓库
软件仓库可以是:HTTP形式、FTP形式、本地ISO形式、本地目录形式

2)URI
关于repo配置文件中各种获取软件方式的书写格式可以参考以下链接:https://en.opensuse.org/openSUSE:Libzypp_URIs
在这里,我把网页上的内容都记录下来,为了以后使用方便

【HTTP/HTTPS/FTP-https涉及到一些参数详见网页跳转,这里不记录了】

You are probably very familiar with these already:

http://server/path/on/server
http://user:pass@server/path
https://user:pass@server/path?proxy=foo&proxyuser=me&proxypass=pw

ftp://server/relative/path/to/media/dir
ftp://server/%2fabsolute/path/to/media/dir

ftp://user:pass@server/path/to/media/dir
ftp://user:pass@server/%2f/home/user/path/to/media/dir


【CD/DVD】

cd:/
cd:/subdir
cd:/?devices=/dev/hda,/dev/hdb
dvd:/
dvd:/subdir
dvd:/?devices=/dev/hda,/dev/hdb

【Local Files】

dir:/directory/name
file:/directory/name

【SMB/CIFS】

cifs://servername/share/path/on/the/share"
cifs://username:passwd@servername/share/path/on/the/share?mountoptions=ro
smb://servername/share/path/on/the/share"
smb://username:passwd@servername/share/path/on/the/share?mountoptions=ro

【NFS】

nfs://nfs-server/exported/path
nfs://nfs-server/exported/path?mountoptions=ro

【HD Disk Volumes】

hd:/?device=/dev/hda1
hd:/subdir?device=/dev/sda1
hd:/subdir?device=/dev/sda1&filesystem=reiserfs

【ISO Images】

iso:/?iso=/path/to/CD1.iso
iso:/?iso=CD1.iso&url=dir:/path/to
iso:/?iso=CD1.iso&url=nfs://server/path/to/media
iso:/?iso=CD1.iso&url=hd:/?device=/dev/hda
iso:/?iso=DVD1.iso&url=hd:/directory/?device=/dev/sda2
iso:/subdir?iso=DVD1.iso&url=nfs://nfs-server/directory&mnt=/nfs/attach/point&filesystem=udf

3)刷新命令
使用刷新命令(zypper ref)也就是意味着从软件仓库中下载关于软件包的元数据(包含各软件包的详细信息,依赖关系等等),并将这些谢谢存储在系统的缓存中(存储路径一般是:/var/cache/zypp)

4)zypper的软件包类型
zypper在实际使用中会涉及到好几种类型的软件包,他们的关系如下:

package-一般是RPM包

patch-升级包(包含一个或多个RPM包)

pattern-安装实现某些功能所需的一组RPM包

product-安装某些产品必须的一组RPM包


2、快速配置

1、列出当前已经存在的所有软件仓库
#zypper repos or zypper lr

2、删除不需要的软件仓库 
#zypper rr SUSE-Linux-Enterprise-Server-11-SP3\ 11.3.3-1.138   #注意这里需要加上转义字符

3、新增软件仓库
#zypper addrepo or zypper ar

3.1、本地ISO方式
NTP-slave:~/ISO # zypper ar iso:/?iso=/root/ISO/SLES11SP3.iso wxh
Adding repository 'wxh' [done]
Repository 'wxh' successfully added
Enabled: Yes
Autorefresh: No
GPG check: Yes
URI: iso:///?iso=/root/ISO/SLES11SP3.iso

NTP-slave:~/ISO # zypper ref
Retrieving repository 'wxh' metadata [done]
Building repository 'wxh' cache [done]
All repositories have been refreshed.


3.2、HTTP方式
suse11sp3-1:~ # zypper ar http://www.watchmen.com/sles11sp3 wxh
Adding repository 'wxh' [done]
Repository 'wxh' successfully added
Enabled: Yes
Autorefresh: No
GPG check: Yes
URI: http://www.watchmen.com/sles11sp3

suse11sp3-1:~ # zypper ref
Retrieving repository 'wxh' metadata [done]
Building repository 'wxh' cache [done]
All repositories have been refreshed.

4、刷新软件源:
# zypper refresh or zypper ref 




结尾:


     感谢阅读,祝有收获的一天,谢谢!



本文出自 “清风揽月的博客” 博客,请务必保留此出处http://watchmen.blog.51cto.com/6091957/1933902