歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> SUSE Linux – Zypper 命令示例

SUSE Linux – Zypper 命令示例

日期:2017/2/28 14:26:01   编辑:Linux教程

Zypper是SUSE Linux中用於安裝,升級,卸載,管理倉庫、進行各種包查詢的命令行接口。本篇將會討論zypper的幾個不同命令的例子。

語法:

  1. # zypper [--global-opts] <command> [--command-opts] [command-arguments]

中括號中的部分可以不需要。執行zypper最簡單的方法是輸入 zypper 及 。

例子1:列出可用的全局選項和命令

打開終端,輸入zypper並按回車,它會顯示所有可用的全局選項和命令。

  1. linux-xa3t:~# zypper

例子2:獲得zypper的某個命令的幫助

語法: zypper help [command]

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

例子3:打開zypper shell/會話

  1. linux-xa3t:~# zypper sh
  2. zypper>

  1. linux-xa3t:~# zypper shell
  2. zypper>

例子4:列出已定義的倉庫

  1. linux-xa3t:~# zypper repos

  1. linux-xa3t:~# zypper lr

4.1) 以表格的形式列出倉庫的URI

4.2) 以優先級列出倉庫

  1. linux-xa3t:~# zypper lr -p

例子5:刷新倉庫

  1. linux-xa3t:~# 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. linux-xa3t:~# 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. linux-xa3t:~# 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.

更多詳情見請繼續閱讀下一頁的精彩內容: http://www.linuxidc.com/Linux/2014-11/109214p2.htm

Copyright © Linux教程網 All Rights Reserved