您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)Linux中如何使用zypper命令,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
zypper 是一個簡單易用的命令行包管理器,它使用了一個軟件包管理庫叫做 libzypp 。Zypper 能夠操作軟件安裝源 (比如 Build Service 或 標(biāo)準(zhǔn) openSUSE 安裝源 ), 搜索軟件包,安裝,刪除,或更新軟件包等等。它能夠作為獨立軟件使用,也可以在腳本中使用,或被其他軟件使用
I. 用zypper管理軟件包
1. 安裝包
語法: # zypper install 示例:安裝Mozilla firefox
[root@linuxprobe ~]# zypper install MozillaFirefoxLoading repository data... Reading installed packages... Resolving package dependencies... The following NEW packages are going to be installed: MozillaFirefox MozillaFirefox-branding-SLED The following packages are not supported by their vendor: MozillaFirefox MozillaFirefox-branding-SLED 2 new packages to install. Overall download size: 964.0 KiB. After the operation, additional 3.4 MiB will be used. Continue? [y/n/?] (y): y Retrieving package MozillaFirefox-3.6.16-0.2.1.x86_64 (1/2), 949.0 KiB (3.4 MiB unpacked) Retrieving: MozillaFirefox-3.6.16-0.2.1.x86_64.rpm [done] Installing: MozillaFirefox-3.6.16-0.2.1 [done] Retrieving package MozillaFirefox-branding-SLED-3.5-1.1.5.x86_64 (2/2), 15.0 KiB (34.0 KiB unpacked) Retrieving: MozillaFirefox-branding-SLED-3.5-1.1.5.x86_64.rpm [done] Installing: MozillaFirefox-branding-SLED-3.5-1.1.5 [done]
2. 安裝源碼包
語法:# zypper source-install 示例:從庫中安裝 apache
[root@linuxprobe ~]# zypper source-install apache2-mod_nssReading installed packages... Loading repository data... Resolving package dependencies... Retrieving package mozilla-nss-devel-3.12.8-1.2.1.x86_64 (2/3), 473.0 KiB (2.6 MiB unpacked) Retrieving: mozilla-nss-devel-3.12.8-1.2.1.x86_64.rpm [done] Installing: mozilla-nss-devel-3.12.8-1.2.1 [done] Retrieving: apache2-mod_nss-1.0.8-17.5.src.rpm [done]
3. 更新包
更新某一軟件包: # zypper update 更新所有軟件包: # zypper update
查看所有可用的更新列表:# zypper list-updates
4. 刪除包
語法:# zypper remove 示例:移除Mozilla Firefox
[root@linuxprobe ~]# zypper remove MozillaFirefoxLoading repository data... Reading installed packages... Resolving package dependencies... The following packages are going to be REMOVED: MozillaFirefox MozillaFirefox-branding-SLED 2 packages to remove. After the operation, 3.4 MiB will be freed. Continue? [y/n/?] (y): y Removing MozillaFirefox-branding-SLED-3.5-1.1.5 [done] Removing MozillaFirefox-3.6.16-0.2.1 [done]
5. 查找包
語法:# zypper search 示例:查找所有usb開頭的軟件包
[root@linuxprobe ~]# zypper search usb*Loading repository data... Reading installed packages... S | Name | Summary | Type --+---------------------+----------------------------------------------------------------+-------- | usb_modeswitch | A mode switching tool for controlling multiple-device USB gear | package | usb_modeswitch-data | A mode switching tool for controlling multiple-device USB gear | package | usbip-devel | Headers and static libraries | package i | usbutils | Tools and libraries for USB devices | package
6. 查看軟件包詳情
語法: zypper info 示例:查看usbutils的信息
[root@linuxprobe ~]# zypper info usbutilsLoading repository data... Reading installed packages... Information for package usbutils: Repository: LINUXPROBE Name: usbutils Version: 0.73-38.19 Arch: x86_64 Vendor: SUSE LINUX Products GmbH, Nuernberg, Germany Support Level: unknown Installed: Yes Status: up-to-date Installed Size: 461.0 KiB Summary: Tools and libraries for USB devices Description: This package contains a utility for inspecting devices connected to USB ports. It requires kernel version 2.3.99-pre7 or newer, or the USB backportwhich was introduced in 2.2.18 (supporting the /proc/bus/usb interface).
7. 打補(bǔ)丁
查看所有可打補(bǔ)丁: zypper patches
安裝指定補(bǔ)?。簔ypper patch
8. 鎖住包
軟件包被鎖之后將不能被移除或升級,下面演示一下如何加鎖
1)加al選項鎖住包文件“usbutils”, al 是 add lock的縮寫
[root@linuxprobe ~] # zypper al usbutilsSpecified lock has been successfully added.
\2) 加ll選項查看所有已被鎖住的軟件包, ll 是 List Locks的縮寫
[root@linuxprobe ~] # zypper ll# | Name | Type | Repository--+-----------------+---------+----------- 1 | usbutils | package | (any)
9. 解鎖包
加rl選項解鎖usbutils, rl 是 remove lock的縮寫
[root@linuxprobe ~] # zypper rl usbutils1 lock has been successfully removed. [root@linuxprobe ~]# zypper llThere are no package locks defined.
II. 用zypper管理倉庫
10. 用zypper添加庫
語法:# zypper addrepo
[root@linuxprobe ~] # zypper addrepo --check --refresh --name "Mozilla-repo" http://download.opensuse.org/repositories/mozilla/SLE_11/ "Mozillarepo"Adding repository 'Mozilla-repo' [done] Repository 'Mozilla-repo' successfully added Enabled: Yes Autorefresh: Yes URI: http://download.opensuse.org/repositories/mozilla/SLE_11/
11. 創(chuàng)建本地庫
我們可以使用zypper從本地目錄中創(chuàng)建一個包含所有rpm文件的本地庫
語法: # zypper addrepo
示例:創(chuàng)建一個名為Linuxprobe_Repo的本地目錄,包含所有rpm文件
[root@linuxprobe ~] # zypper addrepo /var/stormgt/dsminst Linuxprobe_RepoAdding repository 'Linuxprobe_Repo' [done] Repository 'Linuxprobe_Repo' successfully added Enabled: Yes Autorefresh: No URI: dir:///var/stormgt/dsminst [root@linuxprobe ~] # zypper search --repo Linuxprobe_RepoLoading repository data... Reading installed packages... S | Name | Summary | Type --+-------------+-----------------------------------------+-------- i | TIVsm-API | the API | package i | TIVsm-API64 | the API | package i | TIVsm-BA | the Backup Archive Client | package i | gskcrypt32 | IBM GSKit Cryptography Runtime | package i | gskcrypt64 | IBM GSKit Cryptography Runtime | package i | gskssl32 | IBM GSKit SSL Runtime With Acme Toolkit | package i | gskssl64 | IBM GSKit SSL Runtime With Acme Toolkit | package
注:你也可以通過此命令添加NFS或FTP路徑
12. 查看庫
[root@linuxprobe ~] # zypper lr# | Alias | Name | Enabled | Refresh--+--------------------------------------------------+--------------------------------------------------+---------+-------- 1 | Mozillarepo | Mozilla-repo | Yes | Yes 2 | SUSE-Linux-Enterprise-Server-11-SP1 11.1.1-1.152 | SUSE-Linux-Enterprise-Server-11-SP1 11.1.1-1.152 | Yes | Yes
查看repo完整的URI:
[root@linuxprobe ~] # zypper lr --uri# | Alias | Name | Enabled | Refresh | URI--+--------------------------------------------------+--------------------------------------------------+---------+---------+---------------------------------------------------------- 1 | Mozillarepo | Mozilla-repo | Yes | Yes | http://download.opensuse.org/repositories/mozilla/SLE_11/ 2 | SUSE-Linux-Enterprise-Server-11-SP1 11.1.1-1.152 | SUSE-Linux-Enterprise-Server-11-SP1 11.1.1-1.152 | Yes | Yes | http://19.106.65.64/FUSELinux/600RC0
13. 在庫中搜索包
列出指定庫Mozillarepo的所有軟件包
[root@linuxprobe ~] # zypper search --repo MozillarepoLoading repository data... Reading installed packages... S | Name | Summary | Type --+--------------------------------------+-------------------------------------------------------------------------+----------- i | MozillaFirefox | Mozilla Firefox Web Browser | package i | MozillaFirefox-branding-SLED | SLED branding of MozillaFirefox | package | MozillaFirefox-branding-openSUSE | openSUSE branding of MozillaFirefox | package | MozillaFirefox-branding-openSUSE | openSUSE branding of MozillaFirefox | srcpackage
14. 庫重命名
重命名庫可以用 renamerepo 選項
示例:將庫”Linuxprobe_Repo”的名字改成”MyLinuxRepo”
[root@linuxprobe ~] # zypper renamerepo Linuxprobe_Repo MyLinuxRepoRepository 'Linuxprobe_Repo' renamed to 'MyLinuxRepo'.
15. 刪除庫
用removerepo選項來移除庫
[root@linuxprobe ~] # zypper removerepo MyLinuxRepoRemoving repository 'MyLinuxRepo' [done] Repository 'MyLinuxRepo has been removed.
16. 備份庫
用export選項可以備份一系列庫文件
[root@linuxprobe ~] # zypper lr --export /var/tmp/backup.repoRepositories have been successfully exported to /var/tmp/backup.repo.
17. 從備份文件中添加庫
[root@linuxprobe ~] # zypper addrepo /var/tmp/backup.rep
18. 禁用/使用庫
示例: 用 modifyrepo 選項的 -d 參數(shù)來禁用Mozilla庫
[root@linuxprobe ~] # zypper modifyrepo -d MozillarepoRepository 'Mozillarepo' has been successfully disabled.
示例: 用 modifyrepo選項 -e 參數(shù)來允許使用Mozilla庫
[root@linuxprobe ~] # zypper modifyrepo -e MozillarepoRepository 'Mozillarepo' has been successfully enabled.
19. 刷新庫
示例: 刷新Mozilla庫
[root@linuxprobe ~] # zypper refresh MozillarepoRepository 'Mozilla-repo' is up to date. Specified repositories have been refreshed.
示例: 自動刷新指定庫
[root@linuxprobe ~] # zypper modifyrepo --refresh Linuxprobe_RepoAutorefresh has been enabled for repository 'Linuxprobe_Repo'.
關(guān)于“Linux中如何使用zypper命令”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。