SUSE( Software and System Entwicklung,即软件和系统开发。其中‘entwicklung‘是德语,意为开发)Linux 是由 Novell 公司在 Linux 内核基础上建立的操作系统。SUSE Linux 有两个发行分支。其中之一名为 openSUSE,这是一款自由而且免费的操作系统 (free as in speech as well as free as in wine)。该系统由开源社区开发维护,支持一些最新版本的应用软件,其最新的稳定版本为 13.2。

另外一个分支是 SUSE Linux 企业版。该分支是一个为企业及商业化产品设计的 Linux 发行版,包含了大量的企业应用以及适用于商业产品生产环境的特性。其最新的稳定版本为 12。

以下的链接包含了安装企业版 SUSE Linux 服务器的详细信息。

Zypper 和 Yast 是 SUSE Linux 平台上的软件包管理工具,他们的底层使用了 RPM(LCTT 译者注:RPM 最初指 Redhat Pacakge Manager ,现普遍解释为递归短语 RPM Package Manager 的缩写)。

Yast(Yet another Setup Tool )是 OpenSUSE 以及企业版 SUSE 上用于系统管理、设置和配置的工具。

Zypper 是软件包管理器ZYpp的命令行接口,可用于安装、删除SUSE Linux上的软件以及进行系统更新。ZYpp为Zypper和Yast提供底层支持。

本文将介绍实际应用中常见的一些Zypper命令。这些命令用来进行安装、更新、删除等任何软件包管理器所能够胜任的工作。

重要 : 切记所有的这些命令都将在系统全局范围内产生影响,所以必须以 root 身份执行,否则命令将失败。

获取基本的 Zypper 帮助信息

  1. 不带任何选项的执行 zypper, 将输出该命令的全局选项以及子命令列表(LCTT 译者注:全局选项,global option,控制台命令的输入分为可选参数和位置参数两大类。按照习惯,一般可选参数称为选项'option',而位置参数称为参数 'argument')。

    1. # zypper
    2. Usage:
    3. zypper [--global-options]
  2. 获取一个具体的子命令的帮助信息,比如 'in' (install),可以执行下面的命令

    1. # zypper help in

    或者

    1. # zypper help install
    2. install (in) [options] {capability | rpm_file_uri}
    3. Install packages with specified capabilities or RPM files with specified
    4. location. A capability is NAME[.ARCH][OP], where OP is one
    5. of <, <=, =, >=, >.
    6. Command options:
    7. --from <alias|#|URI> Select packages from the specified repository.
    8. -r, --repo <alias|#|URI> Load only the specified repository.
    9. -t, --type Type of package (package, patch, pattern, product, srcpackage).
    10. Default: package.
    11. -n, --name Select packages by plain name, not by capability.
    12. -C, --capability Select packages by capability.
    13. -f, --force Install even if the item is already installed (reinstall),
    14. downgraded or changes vendor or architecture.
    15. --oldpackage Allow to replace a newer item with an older one.
    16. Handy if you are doing a rollback. Unlike --force
    17. it will not enforce a reinstall.
    18. --replacefiles Install the packages even if they replace files from other,
    19. already installed, packages. Default is to treat file conflicts
    20. as an error. --download-as-needed disables the fileconflict check.
    21. ......
  3. 安装之前搜索一个安转包(以 gnome-desktop 为例 )

    1. # zypper se gnome-desktop
    2. Retrieving repository 'openSUSE-13.2-Debug' metadata ............................................................[done]
    3. Building repository 'openSUSE-13.2-Debug' cache .................................................................[done]
    4. Retrieving repository 'openSUSE-13.2-Non-Oss' metadata ......................................................... [done]
    5. Building repository 'openSUSE-13.2-Non-Oss' cache ...............................................................[done]
    6. Retrieving repository 'openSUSE-13.2-Oss' metadata ..............................................................[done]
    7. Building repository 'openSUSE-13.2-Oss' cache ...................................................................[done]
    8. Retrieving repository 'openSUSE-13.2-Update' metadata ...........................................................[done]
    9. Building repository 'openSUSE-13.2-Update' cache ................................................................[done]
    10. Retrieving repository 'openSUSE-13.2-Update-Non-Oss' metadata ...................................................[done]
    11. Building repository 'openSUSE-13.2-Update-Non-Oss' cache ........................................................[done]
    12. Loading repository data...
    13. Reading installed packages...
    14. S | Name | Summary | Type
    15. --+---------------------------------------+-----------------------------------------------------------+-----------
    16. | gnome-desktop2-lang | Languages for package gnome-desktop2 | package
    17. | gnome-desktop2 | The GNOME Desktop API Library | package
    18. | libgnome-desktop-2-17 | The GNOME Desktop API Library | package
    19. | libgnome-desktop-3-10 | The GNOME Desktop API Library | package
    20. | libgnome-desktop-3-devel | The GNOME Desktop API Library -- Development Files | package
    21. | libgnome-desktop-3_0-common | The GNOME Desktop API Library -- Common data files | package
    22. | gnome-desktop-debugsource | Debug sources for package gnome-desktop | package
    23. | gnome-desktop-sharp2-debugsource | Debug sources for package gnome-desktop-sharp2 | package
    24. | gnome-desktop2-debugsource | Debug sources for package gnome-desktop2 | package
    25. | libgnome-desktop-2-17-debuginfo | Debug information for package libgnome-desktop-2-17 | package
    26. | libgnome-desktop-3-10-debuginfo | Debug information for package libgnome-desktop-3-10 | package
    27. | libgnome-desktop-3_0-common-debuginfo | Debug information for package libgnome-desktop-3_0-common | package
    28. | libgnome-desktop-2-17-debuginfo-32bit | Debug information for package libgnome-desktop-2-17 | package
    29. | libgnome-desktop-3-10-debuginfo-32bit | Debug information for package libgnome-desktop-3-10 | package
    30. | gnome-desktop-sharp2 | Mono bindings for libgnome-desktop | package
    31. | libgnome-desktop-2-devel | The GNOME Desktop API Library -- Development Files | packag
    32. | gnome-desktop-lang | Languages for package gnome-desktop | package
    33. | libgnome-desktop-2-17-32bit | The GNOME Desktop API Library | package
    34. | libgnome-desktop-3-10-32bit | The GNOME Desktop API Library | package
    35. | gnome-desktop | The GNOME Desktop API Library | srcpackage
  4. 获取一个模式包的信息(以 lamp_server 为例)。

    1. # zypper info -t pattern lamp_server
    2. Loading repository data...
    3. Reading installed packages...
    4. Information for pattern lamp_server:
    5. ------------------------------------
    6. Repository: openSUSE-13.2-Update
    7. Name: lamp_server
    8. Version: 20141007-5.1
    9. Arch: x86_64
    10. Vendor: openSUSE
    11. Installed: No
    12. Visible to User: Yes
    13. Summary: Web and LAMP Server
    14. Description:
    15. 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,
    16. and scripting languages such as PHP, Python, Ruby on Rails, or Perl.
    17. Contents:
    18. S | Name | Type | Dependency
    19. --+-------------------------------+---------+-----------
    20. | apache2-mod_php5 | package |
    21. | php5-iconv | package |
    22. i | patterns-openSUSE-base | package |
    23. i | apache2-prefork | package |
    24. | php5-dom | package |
    25. | php5-mysql | package |
    26. i | apache2 | package |
    27. | apache2-example-pages | package |
    28. | mariadb | package |
    29. | apache2-mod_perl | package |
    30. | php5-ctype | package |
    31. | apache2-doc | package |
    32. | yast2-http-server | package |
    33. | patterns-openSUSE-lamp_server | package |
  5. 开启一个Zypper Shell 的会话。

    1. # zypper shell

    或者

    1. # zypper sh
    1. zypper> help
    2. Usage:
    3. zypper [--global-options]

注意:在 Zypper shell里面可以通过键入 ‘help‘ 获得全局选项以及子命令的列表。

Zypper 软件库管理

列举已定义的软件库

  1. 使用 'zypper repos' 或者 'zypper lr' 来列举所有已定以的软件库。

    1. # zypper repos

    或者

    1. # zypper lr
    2. | Alias | Name | Enabled | Refresh
    3. --+---------------------------+------------------------------------+---------+--------
    4. 1 | openSUSE-13.2-0 | openSUSE-13.2-0 | Yes | No
    5. 2 | repo-debug | openSUSE-13.2-Debug | Yes | Yes
    6. 3 | repo-debug-update | openSUSE-13.2-Update-Debug | No | Yes
    7. 4 | repo-debug-update-non-oss | openSUSE-13.2-Update-Debug-Non-Oss | No | Yes
    8. 5 | repo-non-oss | openSUSE-13.2-Non-Oss | Yes | Yes
    9. 6 | repo-oss | openSUSE-13.2-Oss | Yes | Yes
    10. 7 | repo-source | openSUSE-13.2-Source | No | Yes
    11. 8 | repo-update | openSUSE-13.2-Update | Yes | Yes
    12. 9 | repo-update-non-oss | openSUSE-13.2-Update-Non-Oss | Yes | Yes
  2. 在表格里面显示 zypper URI

    1. # zypper lr -u
    2. | Alias | Name | Enabled | Refresh | URI
    3. --+---------------------------+------------------------------------+---------+---------+----------------------------------------------------------------
    4. 1 | openSUSE-13.2-0 | openSUSE-13.2-0 | Yes | No | cd:///?devices=/dev/disk/by-id/ata-VBOX_CD-ROM_VB2-01700376
    5. 2 | repo-debug | openSUSE-13.2-Debug | Yes | Yes | http://download.opensuse.org/debug/distribution/13.2/repo/oss/
    6. 3 | repo-debug-update | openSUSE-13.2-Update-Debug | No | Yes | http://download.opensuse.org/debug/update/13.2/
    7. 4 | repo-debug-update-non-oss | openSUSE-13.2-Update-Debug-Non-Oss | No | Yes | http://download.opensuse.org/debug/update/13.2-non-oss/
    8. 5 | repo-non-oss | openSUSE-13.2-Non-Oss | Yes | Yes | http://download.opensuse.org/distribution/13.2/repo/non-oss/
    9. 6 | repo-oss | openSUSE-13.2-Oss | Yes | Yes | http://download.opensuse.org/distribution/13.2/repo/oss/
    10. 7 | repo-source | openSUSE-13.2-Source | No | Yes | http://download.opensuse.org/source/distribution/13.2/repo/oss/
    11. 8 | repo-update | openSUSE-13.2-Update | Yes | Yes | http://download.opensuse.org/update/13.2/
    12. 9 | repo-update-non-oss | openSUSE-13.2-Update-Non-Oss | Yes | Yes | http://download.opensuse.org/update/13.2-non-oss/
  3. 根据优先级列举软件库。

    1. # zypper lr -P
    2. | Alias | Name | Enabled | Refresh | Priority
    3. --+---------------------------+------------------------------------+---------+---------+---------
    4. 1 | openSUSE-13.2-0 | openSUSE-13.2-0 | Yes | No | 99
    5. 2 | repo-debug | openSUSE-13.2-Debug | Yes | Yes | 99
    6. 3 | repo-debug-update | openSUSE-13.2-Update-Debug | No | Yes | 99
    7. 4 | repo-debug-update-non-oss | openSUSE-13.2-Update-Debug-Non-Oss | No | Yes | 99
    8. 5 | repo-non-oss | openSUSE-13.2-Non-Oss | Yes | Yes | 85
    9. 6 | repo-oss | openSUSE-13.2-Oss | Yes | Yes | 99
    10. 7 | repo-source | openSUSE-13.2-Source | No | Yes | 99
    11. 8 | repo-update | openSUSE-13.2-Update | Yes | Yes | 99
    12. 9 | repo-update-non-oss | openSUSE-13.2-Update-Non-Oss | Yes | Yes | 99

刷新软件库

  1. 使用 'zypper refresh' or 'zypper ref' 来刷新 zypper 软件库。

    1. # zypper refresh

    或者

    1. # zypper ref
    2. Repository 'openSUSE-13.2-0' is up to date.
    3. Repository 'openSUSE-13.2-Debug' is up to date.
    4. Repository 'openSUSE-13.2-Non-Oss' is up to date.
    5. Repository 'openSUSE-13.2-Oss' is up to date.
    6. Repository 'openSUSE-13.2-Update' is up to date.
    7. Repository 'openSUSE-13.2-Update-Non-Oss' is up to date.
    8. All repositories have been refreshed.
  2. 刷新一个指定的软件库(以 'repo-non-oss' 为例 )。

    1. # zypper refresh repo-non-oss
    2. Repository 'openSUSE-13.2-Non-Oss' is up to date.
    3. Specified repositories have been refreshed.
  3. 强制更新一个软件库(以 'repo-non-oss' 为例 )。

    1. # zypper ref -f repo-non-oss
    2. Forcing raw metadata refresh
    3. Retrieving repository 'openSUSE-13.2-Non-Oss' metadata ............................................................[done]
    4. Forcing building of repository cache
    5. Building repository 'openSUSE-13.2-Non-Oss' cache ............................................................[done]
    6. Specified repositories have been refreshed.

修改软件库

本文中我们使用‘zypper modifyrepo‘ 或者 ‘zypper mr‘ 来关闭或者开启 zypper 软件库。

  1. 在关闭一个软件库之前,我们需要知道在 zypper 中,每一个软件库有一个唯一的标示数字与之关联,该数字用于打开或者关闭与之相联系的软件库。假设我们需要关闭 'repo-oss' 软件库,那么我们可以通过以下的法来获得该软件库的标志数字。

    1. # zypper lr
    2. | Alias | Name | Enabled | Refresh
    3. --+---------------------------+------------------------------------+---------+--------
    4. 1 | openSUSE-13.2-0 | openSUSE-13.2-0 | Yes | No
    5. 2 | repo-debug | openSUSE-13.2-Debug | Yes | Yes
    6. 3 | repo-debug-update | openSUSE-13.2-Update-Debug | No | Yes
    7. 4 | repo-debug-update-non-oss | openSUSE-13.2-Update-Debug-Non-Oss | No | Yes
    8. 5 | repo-non-oss | openSUSE-13.2-Non-Oss | Yes | Yes
    9. 6 | repo-oss | openSUSE-13.2-Oss | No | Yes
    10. 7 | repo-source | openSUSE-13.2-Source | No | Yes
    11. 8 | repo-update | openSUSE-13.2-Update | Yes | Yes
    12. 9 | repo-update-non-oss | openSUSE-13.2-Update-Non-Oss | Yes | Yes

    从以上输出的列表中我们可以看到 'repo-oss' 库的标示数字是 6,因此通过以下的命令来关闭该库。

    1. # zypper mr -d 6
    2. Repository 'repo-oss' has been successfully disabled.
  2. 如果需要再次开启软件库 ‘repo-oss‘, 接上例,与之相关联的标示数字为 6。

    1. # zypper mr -e 6
    2. Repository 'repo-oss' has been successfully enabled.
  3. 针对某一个软件库(以 'repo-non-oss' 为例 )开启自动刷新( auto-refresh )和 rpm 缓存,并设置该软件库的优先级,比如85。

    1. # zypper mr -rk -p 85 repo-non-oss
    2. Repository 'repo-non-oss' priority has been left unchanged (85)
    3. Nothing to change for repository 'repo-non-oss'.
  4. 对所有的软件库关闭 rpm 文件缓存。

    1. # zypper mr -Ka
    2. RPM files caching has been disabled for repository 'openSUSE-13.2-0'.
    3. RPM files caching has been disabled for repository 'repo-debug'.
    4. RPM files caching has been disabled for repository 'repo-debug-update'.
    5. RPM files caching has been disabled for repository 'repo-debug-update-non-oss'.
    6. RPM files caching has been disabled for repository 'repo-non-oss'.
    7. RPM files caching has been disabled for repository 'repo-oss'.
    8. RPM files caching has been disabled for repository 'repo-source'.
    9. RPM files caching has been disabled for repository 'repo-update'.
    10. RPM files caching has been disabled for repository 'repo-update-non-oss'.
  5. 对所有的软件库开启 rpm 文件缓存。

    1. # zypper mr -ka
    2. RPM files caching has been enabled for repository 'openSUSE-13.2-0'.
    3. RPM files caching has been enabled for repository 'repo-debug'.
    4. RPM files caching has been enabled for repository 'repo-debug-update'.
    5. RPM files caching has been enabled for repository 'repo-debug-update-non-oss'.
    6. RPM files caching has been enabled for repository 'repo-non-oss'.
    7. RPM files caching has been enabled for repository 'repo-oss'.
    8. RPM files caching has been enabled for repository 'repo-source'.
    9. RPM files caching has been enabled for repository 'repo-update'.
    10. RPM files caching has been enabled for repository 'repo-update-non-oss'.
  6. 关闭远程库的 rpm 文件缓存

    1. # zypper mr -Kt
    2. RPM files caching has been disabled for repository 'repo-debug'.
    3. RPM files caching has been disabled for repository 'repo-debug-update'.
    4. RPM files caching has been disabled for repository 'repo-debug-update-non-oss'.
    5. RPM files caching has been disabled for repository 'repo-non-oss'.
    6. RPM files caching has been disabled for repository 'repo-oss'.
    7. RPM files caching has been disabled for repository 'repo-source'.
    8. RPM files caching has been disabled for repository 'repo-update'.
    9. RPM files caching has been disabled for repository 'repo-update-non-oss'.
  7. 开启远程软件库的 rpm 文件缓存。

    1. # zypper mr -kt
    2. RPM files caching has been enabled for repository 'repo-debug'.
    3. RPM files caching has been enabled for repository 'repo-debug-update'.
    4. RPM files caching has been enabled for repository 'repo-debug-update-non-oss'.
    5. RPM files caching has been enabled for repository 'repo-non-oss'.
    6. RPM files caching has been enabled for repository 'repo-oss'.
    7. RPM files caching has been enabled for repository 'repo-source'.
    8. RPM files caching has been enabled for repository 'repo-update'.
    9. RPM files caching has been enabled for repository 'repo-update-non-oss'.

增加新的软件库

可以通过这两个 zypper 指令 – 'zypper addrepo' 和 'zypper ar' 来增加新的软件库。在此过程中可以使用 URL 或者软件库的别名。

  1. 增加一个新的软件库( 以 “http://download.opensuse.org/update/12.3/” 为例 )。

    1. # zypper ar http://download.opensuse.org/update/11.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/11.1/
  2. 更改一个软件库的名字,这将仅仅改变软件库的别名。 命令 'zypper namerepo' 或者 'zypperr nr' 可以胜任此工作。例如更改标示数字为10的软件库的名字为 'upd8',或者说将标示数字为10的软件库的别名改为 'upd8',可以使用下面的命令。

    1. # zypper nr 10 upd8
    2. Repository 'update' renamed to 'upd8'.

删除软件库

  1. 删除一个软件库。要从系统删除一个软件库可以使 'zypper removerepo' 或者 'zypper rr'。例如以下的命令可以删除软件库 'upd8'

    1. # zypper rr upd8
    2. # Removing repository 'upd8' .........................................................................................[done]
    3. Repository 'upd8' has been removed.

来源:https://linux.cn/article-5606-1.html

用于 ‘Suse‘ Linux 包管理的 Zypper 命令大全的更多相关文章

  1. Linux 包管理

    1 文集 <Linux 包管理基础:apt.yum.dnf 和 pkg>,由Snapcrafter翻译,英文原创(作者Brennen)地址在这里. 这是一篇不错的概括性的文章,系统介绍了D ...

  2. Linux文本文件——管理文本的命令

    Linux文本文件——管理文本的命令 摘要:本文主要学习了在Linux中管理文本的命令. cat命令 cat命令用来显示文本文件的内容,也可以把几个文件内容附加到另一个文件中,即连接合并文件,是Con ...

  3. Linux后台进程管理的一些命令小结

    Linux后台进程管理的一些命令:fg.bg.jobs.&.ctrl + z命令,供大家学习参考   一. &加在一个命令的最后,可以把这个命令放到后台执行 ,如gftp &, ...

  4. 编码神器——Sublime Text 包管理工具及扩展大全

    Sublime Text 是程序员们公认的编码神奇,拥有漂亮的用户界面和强大的功能,例如代码缩略图,多重选择,快捷命令等.还可自定义键绑定,菜单和工具栏.Sublime Text 的主要功能包括:拼写 ...

  5. SUSE Linux--zypper程序包管理(实战命令总结)

    (1)zypper ar iso:/?iso=/media/SOFTWARE/openSUSE-11.4-DVD-i586.iso DVDISO 新添加本地iso文件为安装源,名称和别名均为DVDIS ...

  6. 笔记-Linux包管理命令

    一.apt, apt-get, dpkg命令 apt-get是一条linux命令,适用于deb包管理式的操作系统,主要用于自动从互联网的软件仓库中搜索.安装.升级.卸载软件或操作系统.使用apt-ge ...

  7. Linux包管理器

    按Linux系统分类 Redhat系列:Redhat(本身就是Centos).Centos.Fedora等,采用Dpkg包管理器 Debian系列:Debian.Ubuntu等,使用RPM包管理器 R ...

  8. Linux包管理

    1.yum(Yellow dog Updater, Modified) yum是一个在Fedora(基于Linux的操作系统)和RedHat(基于Linux的操作系统)以及SUSE(基于Linux的操 ...

  9. Linux包管理工具分析

    转自:http://blog.csdn.net/carolzhang8406/article/details/14198219 在正式进入讨论之前,先贴几条非常有用的link: linux 发行版比较 ...

随机推荐

  1. paper 50 :人脸识别简史与近期进展

    自动人脸识别的经典流程分为三个步骤:人脸检测.面部特征点定位(又称Face Alignment人脸对齐).特征提取与分类器设计.一般而言,狭义的人脸识别指的是"特征提取+分类器"两 ...

  2. html5,表格

    <table border="1"><caption>表格的实例</caption><tr><td>单元格</td ...

  3. Android webview实现上传图片的效果(图片压缩)

    mainactivity代码 package com.bwie.webviewupload; import java.io.ByteArrayInputStream; import java.io.B ...

  4. VS2010 断点无效肿么办?

    [1]分析原理: 1. 断点无效是因为目标文件和源文件的更新时间不一致, 编译器不认为当前的源文件是目标文件的当前版本. 2. IDE不会关心源文件的编码格式,能读入即可, 另存为Unicode或AS ...

  5. json_decode和json_encode

    JSON出错:Cannot use object of type stdClass as array解决方法php再调用json_decode从字符串对象生成json对象时,如果使用[]操作符取数据, ...

  6. php的ssh2扩展安装

    折腾半天,结论如下: 1.先需要openssl 用which openssl看是否已安装 2.然后libssh2 用rpm -ql libssh2查看 3.下载源码的shh2x.x.x.tgz的包 4 ...

  7. 设置eclipse补全方法

    开MyEclipse 6.0. 1,然后“window”→“Preferences” 2,选择“java”,展开,“Editor”,选择“Content Assist”. 3,选择“Content A ...

  8. 今天 同一个Nav 左右button 替换不显示的问题 viewDidLoad, viewWillDisappear, viewWillAppear等区别及各自的加载顺序

    viewWillAppear:  Called when the view is about to made visible. Default does nothing视图即将可见时调用.默认情况下不 ...

  9. 为Docker容器配置固定IP

    当docker以桥接的方式启动容器时,容器内部的IP是经过DHCP获取的,例如:172.17.0.8/32,且每重启依次IP都会发生变动.某些特殊的情况下,需要容器内有自己固定的一个内部IP.我的实现 ...

  10. Centos6.5和Centos7 php环境搭建如何实现呢

    首先我们先查看下centos的版本信息 代码如下: #适用于所有的linux lsb_release -a#或者cat /etc/redhat-release#又或者rpm -q centos-rel ...