新聞中心
zypper 是一個簡單易用的命令行包管理器,它使用了一個軟件包管理庫叫做 libzypp 。Zypper 能夠操作軟件安裝源 (比如 Build Service 或 標(biāo)準(zhǔn) openSUSE 安裝源 ), 搜索軟件包,安裝,刪除,或更新軟件包等等。它能夠作為獨立軟件使用,也可以在腳本中使用,或被其他軟件使用,下面為大家分享一下Linux系統(tǒng)zypper命令使用實例。

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:空間域名、雅安服務(wù)器托管、營銷軟件、網(wǎng)站建設(shè)、宜君網(wǎng)站維護、網(wǎng)站推廣。
zypper命令使用實例
I. 用zypper管理軟件包
1. 安裝包
語法: # zypper install 示例:安裝Mozilla firefox
[root@linuxprobe ~]# zypper install MozillaFirefox
Loading 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_nss
Reading 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 MozillaFirefox
Loading 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 usbutils
Loading 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 backport
which was introduced in 2.2.18 (supporting the /proc/bus/usb
interface).
7. 打補丁
查看所有可打補丁: zypper patches
安裝指定補?。簔ypper patch
8. 鎖住包
軟件包被鎖之后將不能被移除或升級,下面演示一下如何加鎖
1)加al選項鎖住包文件“usbutils”, al 是 add lock的縮寫
[root@linuxprobe ~] # zypper al usbutils
Specified 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 usbutils
1 lock has been successfully removed.
[root@linuxprobe ~]# zypper ll
There 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_Repo
Adding repository 'Linuxprobe_Repo' [done]
Repository 'Linuxprobe_Repo' successfully added
Enabled: Yes
Autorefresh: No
URI: dir:///var/stormgt/dsminst
[root@linuxprobe ~] # zypper search --repo Linuxprobe_Repo
Loading 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 Mozillarepo
Loading 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 MyLinuxRepo
Repository 'Linuxprobe_Repo' renamed to 'MyLinuxRepo'.
15. 刪除庫
用removerepo選項來移除庫
[root@linuxprobe ~] # zypper removerepo MyLinuxRepo
Removing repository 'MyLinuxRepo' [done]
Repository 'MyLinuxRepo has been removed.
16. 備份庫
用export選項可以備份一系列庫文件
[root@linuxprobe ~] # zypper lr --export /var/tmp/backup.repo
Repositories 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 Mozillarepo
Repository 'Mozillarepo' has been successfully disabled.
示例: 用 modifyrepo選項 -e 參數(shù)來允許使用Mozilla庫
[root@linuxprobe ~] # zypper modifyrepo -e Mozillarepo
Repository 'Mozillarepo' has been successfully enabled.
19. 刷新庫
示例: 刷新Mozilla庫
[root@linuxprobe ~] # zypper refresh Mozillarepo
Repository 'Mozilla-repo' is up to date.
Specified repositories have been refreshed.
示例: 自動刷新指定庫
[root@linuxprobe ~] # zypper modifyrepo --refresh Linuxprobe_Repo
Autorefresh has been enabled for repository 'Linuxprobe_Repo'.
標(biāo)題名稱:Linux系統(tǒng)zypper命令使用實例
鏈接URL:http://fisionsoft.com.cn/article/djdjois.html


咨詢
建站咨詢
