这篇文章将为大家详细讲解有关Linux中如何使用zypper命令,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
zypper 是一个简单易用的命令行包管理器,它使用了一个软件包管理库叫做 libzypp 。Zypper 能够操作软件安装源 (比如 Build Service 或 标准 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. 打补丁
查看所有可打补丁: zypper patches
安装指定补丁:zypper 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. 创建本地库
我们可以使用zypper从本地目录中创建一个包含所有rpm文件的本地库
语法: # zypper addrepo
示例:创建一个名为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 参数来禁用Mozilla库
[root@linuxprobe ~] # zypper modifyrepo -d MozillarepoRepository 'Mozillarepo' has been successfully disabled.
示例: 用 modifyrepo选项 -e 参数来允许使用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'.
关于“Linux中如何使用zypper命令”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。