首页 > 代码库 > zypper基本用法和实际操作

zypper基本用法和实际操作

操作环境:仅限于SUSE操作系统


1.列出软件源

#zypper sl (等同于zypper repos)(等同于zypper service-list)

  | Alias                                            | Name                                             | Enabled | Refresh

--+--------------------------------------------------+--------------------------------------------------+---------+--------

1   update                                           | update                                           | Yes     | No   



2.添加软件源

方法一:

#zypper sa http://yast.tencentyun.com/ SUSE10-SP4


方法二:

#zypper addrepo -f http://ftp.gwdg.de/pub/linux/packman/suse/13.1/ packman

(前提是设置DNS域名服务器,否则失效)


方法三:

#zypper addrepo iso:/?iso=/opt/SLES-11-SP2-DVD-x86_64-GM-DVD1.iso DVD2

(将SLES-11-SP2-DVD-x86_64-GM-DVD1.iso光盘上传到/opt目录)


Adding repository ‘DVD2‘ [done]

Repository ‘DVD2‘ successfully added

Enabled: Yes

Autorefresh: No

GPG check: Yes

URI: iso:///?iso=/mnt/share/SLES-11-SP2-DVD-x86_64-GM-DVD2.iso



***********************************************

实战过程中,执行上面的命令出现如下的错误:

Specified path ‘/var/cache/zypp/raw/DVD1‘ is not a directory: dir:///var/cache/zypp/raw/DVD1


Abort, retry, ignore? [a/r/i/?] (a): i

Error building the cache:

Unknown error reading from ‘dir:///var/cache/zypp/raw/DVD2‘

Warning: Disabling repository ‘DVD2‘ because of the above error.

Empty destination in URI: hd:///?device=/dev/sdb4


重新添加一次:

#zypper addrepo iso:/?iso=/opt/SLES-11-SP2-DVD-x86_64-GM-DVD1.iso DVD1

************************************************





3.删除软件源

# zypper sd update(名字或者别名)

注意:删除yast2添加的软件源会出现如下的异常,所以需要进入图形化界面进行修改)

# zypper sd SUSE-Linux-Enterprise-Server-11-SP2 11.2.2-1.234

Service ‘SUSE-Linux-Enterprise-Server-11-SP2‘ not found by alias, number or URI.

Service ‘11.2.2-1.234‘ not found by alias, number or URI.


4.搜索软件包

技巧:

1.安装iostat命令

#zypper se iostat

 no packages found

2.搜索stat关键字

#zypper  se stat

S | Name              | Summary                                            | Type      

--+-------------------+----------------------------------------------------+-----------

  | kdirstat          | Graphical Directory Statistics for Used Disk Space | package   

  | kdirstat          | Graphical Directory Statistics for Used Disk Space | srcpackage

  | sdpnetstat        | netstat for SDP                                    | package   

  | sdpnetstat        | netstat for SDP                                    | srcpackage

  | statserial        | Helps to Debug Serial Lines                        | package   

  | statserial        | Helps to Debug Serial Lines                        | srcpackage

i | sysstat           | Sar and Iostat Commands for Linux                  | package   

  | sysstat           | Sar and Iostat Commands for Linux                  | srcpackage

  | sysstat-isag      | Interactive System Activity Grapher for sysstat    | package   

i | yast2-trans-stats | YaST2 - Translation Statistics                     | package   

  | yast2-trans-stats | YaST2 - Translation Statistics                     | srcpackage



5.安装软件包:

#zypper in sysstat





zypper基本用法和实际操作