Zypper是SUSE Linux中用於安裝,升級,卸載,管理倉庫、進行各種包查詢的命令行接口。本篇將會討論zypper的幾個不同命令的例子。
語法:
- # zypper [--global-opts] <command> [--command-opts] [command-arguments]
中括號中的部分可以不需要。執行zypper最簡單的方法是輸入 zypper 及 。
例子1:列出可用的全局選項和命令
打開終端,輸入zypper並按回車,它會顯示所有可用的全局選項和命令。
- linux-xa3t:~# zypper
例子2:獲得zypper的某個命令的幫助
語法: zypper help [command]
- linux-xa3t:~# zypper help remove
- remove (rm)[options]<capability>...
-
- Remove packages with specified capabilities.
- A capability is NAME[.ARCH][OP<VERSION>],where OP is one of <,<=,=,>=,>.
-
- Command options:
- -r,--repo <alias|#|URI>Load only the specified repository.
- -t,--type <type>Type of package(package, patch, pattern, product).
-
- Default:package.
- -n,--name Select packages by plain name,notby capability.
- -C,--capability Select packages by capability.
- --debug-solver Create solver test casefor debugging.
- -R,--no-force-resolution Donot force the solver to find solution,let it ask.
- --force-resolution Force the solver to find a solution (even an aggressive one).
- -u,--clean-deps Automatically remove unneeded dependencies.
- -U,--no-clean-deps No automatic removal of unneeded dependencies.
- -D,--dry-run Test the removal,donot actually remove.
例子3:打開zypper shell/會話
- linux-xa3t:~# zypper sh
- zypper>
或
- linux-xa3t:~# zypper shell
- zypper>
例子4:列出已定義的倉庫
- linux-xa3t:~# zypper repos
或
- linux-xa3t:~# zypper lr
4.1) 以表格的形式列出倉庫的URI
4.2) 以優先級列出倉庫
- linux-xa3t:~# zypper lr -p
例子5:刷新倉庫
- linux-xa3t:~# zypper ref
- Repository'openSUSE-13.1-Non-Oss'is up to date.
- Repository'openSUSE-13.1-Oss'is up to date.
- Repository'openSUSE-13.1-Update'is up to date.
- Repository'openSUSE-13.1-Update-Non-Oss'is up to date.
- 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或者別名>
- linux-xa3t:~# zypper ar http://download.opensuse.org/update/13.1/ update
- Adding repository 'update'.............................................[done]
- Repository'update' successfully added
- Enabled:Yes
- Autorefresh:No
- GPG check:Yes
- URI: http://download.opensuse.org/update/13.1/
例子8:移除倉庫
語法: zypper removerepo <倉庫名> <別名>
或者
zypper rr <倉庫名> <別名>
- linux-xa3t:~# zypper rr openSUSE-13.1-1.10 openSUSE-13.1-1.10
- Removing repository 'openSUSE-13.1-1.10'............................[done]
- Repository'openSUSE-13.1-1.10' has been removed.
更多詳情見請繼續閱讀下一頁的精彩內容: http://www.linuxidc.com/Linux/2014-11/109214p2.htm