歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux管理 >> Linux維護 >> SUSE Linux系統中zypper命令用法匯總

SUSE Linux系統中zypper命令用法匯總

日期:2017/3/2 10:31:06   编辑:Linux維護

Zypper是SUSE Linux下用於管理軟件的程序,擁有多種功能,那麼Linux下要如何使用Zypper命令來管理軟件呢?下面小編就給大家介紹下SUSE Linux使用Zypper命令的方法,感興趣的朋友可以來了解下。

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.

例子9:安裝軟件包

語法: zypper install 《包名》 或者 zypper in 《包名》

linux-xa3t:~# zypper install vlc

例子10:卸載軟件包

語法: zypper remove 《包名》 或者 zypper rm 《包名》

linux-xa3t:~# zypper remove sqlite

例子11:導出和導入倉庫

導出倉庫的語法 : zypper repos –export 或者 zypper lr -e

linux-xa3t:~# zypper lr --export repo-backup/back.repo

Repositories have been successfully exported to repo-backup/back.repo.

導入倉庫的語法 :

linux-xa3t:~# zypper ar repo-backup/back.repo

例子12:更新一個軟件包

語法: zypper update 《包名》 或者 zypper up 《包名》

linux-xa3t:~# zypper update bash

例子13:安裝源碼包

語法: zypper source-install 《源碼包》 或 zypper si 《源碼包》

linux-xa3t:~# zypper source-install zypper

例子14:只安裝依賴包

例子13中的命令會安裝和構建特定包的依賴。如果你想要安裝源碼包就用-D選項

# zypper source-install -D package_name

只安裝依賴就使用-d

# zypper source-install -d package_name

上面就是SUSE Linux系統中Zypper命令操作實例的相關介紹了,通過這些實例想必你已經對Zypper命令有一定的了解,希望對你有所幫助。

Copyright © Linux教程網 All Rights Reserved