SUSE Linux – Zypper 命令示例

<

div id=”content” contentScore=”1099″>Zypper是SUSE Linux中用于安装,升级,卸载,管理仓库、进行各种包查询的命令行接口。本篇将会讨论zypper的几个不同命令的例子。

语法:

  1. # zypper [–global-opts] [–command-opts] [command-arguments]

中括号中的部分可以不需要。执行zypper最简单的方法是输入 zypper 及 。

例子1:列出可用的全局选项和命令

打开终端,输入zypper并按回车,它会显示所有可用的全局选项和命令。

  1. linuxxa3t:~# zypper

例子2:获得zypper的某个命令的帮助

语法: zypper help [command]

  1. linuxxa3t:~# zypper help remove
  2. remove (rm)[options]
  3.  
  4. Remove packages with specified capabilities.
  5. A capability is NAME[.ARCH][OP<VERSION>],where OP is one of <,<=,=,>=,>.
  6.  
  7. Command options:
  8. r,repo <alias|#|URI>Load only the specified repository.
  9. t,type Type of package(package, patch, pattern, product).
  10.  
  11. Default:package.
  12. n,name Select packages by plain name,notby capability.
  13. C,capability Select packages by capability.
  14. debugsolver Create solver test casefor debugging.
  15. R,noforceresolution Donot force the solver to find solution,let it ask.
  16. forceresolution Force the solver to find a solution (even an aggressive one).
  17. u,cleandeps Automatically remove unneeded dependencies.
  18. U,nocleandeps No automatic removal of unneeded dependencies.
  19. D,dryrun Test the removal,donot actually remove.

例子3:打开zypper shell/会话

  1. linuxxa3t:~# zypper sh
  2. zypper>

  1. linuxxa3t:~# zypper shell
  2. zypper>

例子4:列出已定义的仓库

  1. linuxxa3t:~# zypper repos

  1. linuxxa3t:~# zypper lr

4.1) 以表格的形式列出仓库的URI

4.2) 以优先级列出仓库

  1. linuxxa3t:~# zypper lr -p

例子5:刷新仓库

  1. linuxxa3t:~# zypper ref
  2. Repository‘openSUSE-13.1-Non-Oss’is up to date.
  3. Repository‘openSUSE-13.1-Oss’is up to date.
  4. Repository‘openSUSE-13.1-Update’is up to date.
  5. Repository‘openSUSE-13.1-Update-Non-Oss’is up to date.
  6. All repositories have been refreshed.

例子6:修改zypper仓库

zypper仓库可以通过别名、数字或者URI或者通过‘–all、 –remote、 –local、 –medium-type’这些选项修改。

linux-xa3t:~ # zypper mr -d 6 #禁用6号仓库 linux-xa3t:~ # zypper mr -rk -p 70 upd #启用自动书信并为‘upd’仓库设置rpm文件‘缓存’,且设置它的优先级为70 linux-xa3t:~ # zypper mr -Ka #为所有的仓库禁用rpm文件缓存 linux-xa3t:~ # zypper mr -kt #为远程仓库设置rpm文件缓存

例子7:添加仓库

语法: zypper addrepo 或者 zypper ar <仓库的URL或者别名>

  1. linuxxa3t:~# zypper ar http://download.opensuse.org/update/13.1/ update
  2. Adding repository ‘update’………………………………………[done]
  3. Repository‘update’ successfully added
  4. Enabled:Yes
  5. Autorefresh:No
  6. GPG check:Yes
  7. URI: http://download.opensuse.org/update/13.1/

例子8:移除仓库

语法: zypper removerepo <仓库名> <别名>

或者

zypper rr <仓库名> <别名>

  1. linuxxa3t:~# zypper rr openSUSE-13.1-1.10 openSUSE-13.1-1.10
  2. Removing repository ‘openSUSE-13.1-1.10’……………………….[done]
  3. Repository‘openSUSE-13.1-1.10’ has been removed.

更夼/div>