zypper 是 Suse Linux 系统的包和补丁管理器,你可以根据下面的 12 条附带输出示例的实用范例来学习 zypper 命令的使用。

Suse Linux 使用 zypper 进行包管理,其是一个由 ZYpp 包管理引擎提供的包管理系统。在此篇文章中我们将分享 12 条附带输出示例的实用 zypper 命令,能帮助你处理日常的系统管理任务。

不带参数的 zypper 命令将列出所有可用的选项,这比参考详细的 man 手册要容易上手得多。

root@kerneltalks # zypper

用法:

zypper [--global-options] [--command-options] [arguments]

zypper [--command-options] [arguments]

全局选项:

--help, -h 帮助

--version, -V 输出版本号

--promptids 输出 zypper 用户提示符列表

--config, -c 使用指定的配置文件来替代默认的

--userdata 在历史和插件中使用的用户自定义事务 id

--quiet, -q 忽略正常输出,只打印错误信息

--verbose, -v 增加冗长程度

--color

--no-color 是否启用彩色模式,如果 tty 支持的话

--no-abbrev, -A 表格中的文字不使用缩写

--table-style, -s 表格样式(整型)

--non-interactive, -n 不询问任何选项,自动使用默认答案

--non-interactive-include-reboot-patches

针对带有重启标志的补丁,不使用交互模式

--xmlout, -x 切换至 XML 输出

--ignore-unknown, -i 忽略未知的包

--reposd-dir, -D

--cache-dir, -C

--raw-cache-dir

--solv-cache-dir

--pkg-cache-dir

仓库选项:

--no-gpg-checks 忽略 GPG 检查失败并跳过

--gpg-auto-import-keys 自动信任并导入新仓库的签名密钥

--plus-repo, -p 使用附加仓库

--plus-content 另外使用禁用的仓库来提供特定的关键词

尝试使用 '--plus-content debug' 选项来启用仓库

--disable-repositories 不从仓库中读取元数据

--no-refresh 不刷新仓库

--no-cd 忽略 CD/DVD 中的仓库

--no-remote 忽略远程仓库

--releasever 设置所有 .repo 文件中的 $releasever 变量(默认值:发行版版本)

Target Options:

--root, -R

--disable-system-resolvables

不读取已安装包

命令:

help, ? 打印帮助

shell, sh 允许多命令

仓库管理:

repos, lr 列出所有自定义仓库

addrepo, ar 添加一个新仓库

removerepo, rr 移除指定仓库

renamerepo, nr 重命名指定仓库

modifyrepo, mr 修改指定仓库

refresh, ref 刷新所有仓库

clean 清除本地缓存

服务管理:

services, ls 列出所有自定义服务

addservice, as 添加一个新服务

modifyservice, ms 修改指定服务

removeservice, rs 移除指定服务

refresh-services, refs 刷新所有服务

软件管理:

install, in 安装包

remove, rm 移除包

verify, ve 确认包依赖的完整性

source-install, si 安装源码包及其构建依赖

install-new-recommends, inr

安装由已安装包建议一并安装的新包

更新管理:

update, up 更新已安装包至更新版本

list-updates, lu 列出可用更新

patch 安装必要的补丁

list-patches, lp 列出必要的补丁

dist-upgrade, dup 进行发行版更新

patch-check, pchk 检查补丁

查询:

search, se 查找符合匹配模式的包

info, if 展示特定包的完全信息

patch-info 展示特定补丁的完全信息

pattern-info 展示特定模式的完全信息

product-info 展示特定产品的完全信息

patches, pch 列出所有可用的补丁

packages, pa 列出所有可用的包

patterns, pt 列出所有可用的模式

products, pd 列出所有可用的产品

what-provides, wp 列出提供特定功能的包

包锁定:

addlock, al 添加一个包锁定

removelock, rl 移除一个包锁定

locks, ll 列出当前的包锁定

cleanlocks, cl 移除无用的锁定

其他命令:

versioncmp, vcmp 比较两个版本字符串

targetos, tos 打印目标操作系统 ID 字符串

licenses 打印已安装包的证书和 EULAs 报告

download 使用命令行下载指定 rpm 包到本地目录

source-download 下载所有已安装包的源码 rpm 包到本地目录

子命令:

subcommand 列出可用子命令

输入 'zypper help ' 来获得特定命令的帮助。

如何使用 zypper 安装包

zypper 通过 in 或 install 子命令来在你的系统上安装包。它的用法与 yum 软件包安装 相同。你只需要提供包名作为参数,包管理器(此处是 zypper)就会处理所有的依赖并与你指定的包一并安装。

# zypper install telnet

Refreshing service 'SMT-http_smt-ec2_susecloud_net'.

Refreshing service 'cloud_update'.

Loading repository data...

Reading installed packages...

Resolving package dependencies...

The following NEW package is going to be installed:

telnet

1 new package to install.

Overall download size: 51.8 KiB. Already cached: 0 B. After the operation, additional 113.3 KiB will be used.

Continue? [y/n/...? shows all options] (y): y

Retrieving package telnet-1.2-165.63.x86_64 (1/1), 51.8 KiB (113.3 KiB unpacked)

Retrieving: telnet-1.2-165.63.x86_64.rpm .........................................................................................................................[done]

Checking for file conflicts: .....................................................................................................................................[done]

(1/1) Installing: telnet-1.2-165.63.x86_64 .......................................................................................................................[done]

以上是我们安装 telnet 包时的输出,供你参考。

如何使用 zypper 移除包

要在 Suse Linux 中擦除或移除包,使用 zypper 附带 remove 或 rm 子命令。

root@kerneltalks # zypper rm telnet

Loading repository data...

Reading installed packages...

Resolving package dependencies...

The following package is going to be REMOVED:

telnet

1 package to remove.

After the operation, 113.3 KiB will be freed.

Continue? [y/n/...? shows all options] (y): y

(1/1) Removing telnet-1.2-165.63.x86_64 ..........................................................................................................................[done]

我们在此处移除了先前安装的 telnet 包。

使用 zypper 检查依赖或者认证已安装包的完整性

有时可以通过强制忽略依赖关系来安装软件包。zypper 使你能够扫描所有已安装的软件包并检查其依赖性。如果缺少任何依赖项,它将提供你安装或重新安装它的机会,从而保持已安装软件包的完整性。

使用附带 verify 或 ve 子命令的 zypper 命令来检查已安装包的完整性。

root@kerneltalks # zypper ve

Refreshing service 'SMT-http_smt-ec2_susecloud_net'.

Refreshing service 'cloud_update'.

Loading repository data...

Reading installed packages...

Dependencies of all installed packages are satisfied.

在上面的输出中,你能够看到最后一行说明已安装包的所有依赖都已安装完全,并且无需更多操作。

如何在 Suse Linux 中使用 zypper 下载包

zypper 提供了一种方法使得你能够将包下载到本地目录而不去安装它。你可以在其他具有同样配置的系统上使用这个已下载的软件包。包会被下载至 /var/cache/zypp/packages/// 目录。

root@kerneltalks # zypper download telnet

Refreshing service 'SMT-http_smt-ec2_susecloud_net'.

Refreshing service 'cloud_update'.

Loading repository data...

Reading installed packages...

Retrieving package telnet-1.2-165.63.x86_64 (1/1), 51.8 KiB (113.3 KiB unpacked)

(1/1) /var/cache/zypp/packages/SMT-http_smt-ec2_susecloud_net:SLES12-SP3-Pool/x86_64/telnet-1.2-165.63.x86_64.rpm ................................................[done]

download: Done.

# ls -lrt /var/cache/zypp/packages/SMT-http_smt-ec2_susecloud_net:SLES12-SP3-Pool/x86_64/

total 52

-rw-r--r-- 1 root root 53025 Feb 21 03:17 telnet-1.2-165.63.x86_64.rpm

你能看到我们使用 zypper 将 telnet 包下载到了本地。

如何使用 zypper 列出可用包更新

zypper 允许你浏览已安装包的所有可用更新,以便你可以提前计划更新活动。使用 list-updates 或 lu 子命令来显示已安装包的所有可用更新。

root@kerneltalks # zypper lu

Refreshing service 'SMT-http_smt-ec2_susecloud_net'.

Refreshing service 'cloud_update'.

Loading repository data...

Reading installed packages...

S | Repository | Name | Current Version | Available Version | Arch

--|-----------------------------------|----------------------------|-------------------------------|------------------------------------|-------

v | SLES12-SP3-Updates | at-spi2-core | 2.20.2-12.3 | 2.20.2-14.3.1 | x86_64

v | SLES12-SP3-Updates | bash | 4.3-82.1 | 4.3-83.5.2 | x86_64

v | SLES12-SP3-Updates | ca-certificates-mozilla | 2.7-11.1 | 2.22-12.3.1 | noarch

v | SLE-Module-Containers12-Updates | containerd | 0.2.5+gitr639_422e31c-20.2 | 0.2.9+gitr706_06b9cb351610-16.8.1 | x86_64

v | SLES12-SP3-Updates | crash | 7.1.8-4.3.1 | 7.1.8-4.6.2 | x86_64

v | SLES12-SP3-Updates | rsync | 3.1.0-12.1 | 3.1.0-13.10.1 | x86_64

输出特意被格式化以便于阅读。每一列分别代表包所属仓库名称、包名、已安装版本、可用的更新版本和架构。

在 Suse Linux 中列出和安装补丁

使用 list-patches 或 lp 子命令来显示你的 Suse Linux 系统需要被应用的所有可用补丁。

root@kerneltalks # zypper lp

Refreshing service 'SMT-http_smt-ec2_susecloud_net'.

Refreshing service 'cloud_update'.

Loading repository data...

Reading installed packages...

Repository | Name | Category | Severity | Interactive | Status | Summary

----------------------------------|------------------------------------------|-------------|-----------|-------------|--------|------------------------------------------------------------------------------------

SLE-Module-Containers12-Updates | SUSE-SLE-Module-Containers-12-2018-273 | security | important | --- | needed | Version update for docker, docker-runc, containerd, golang-github-docker-libnetwork

SLE-Module-Containers12-Updates | SUSE-SLE-Module-Containers-12-2018-62 | recommended | low | --- | needed | Recommended update for sle2docker

SLE-Module-Public-Cloud12-Updates | SUSE-SLE-Module-Public-Cloud-12-2018-268 | recommended | low | --- | needed | Recommended update for python-ecdsa

SLES12-SP3-Updates | SUSE-SLE-SERVER-12-SP3-2018-116 | security | moderate | --- | needed | Security update for rsync

---- output clipped ----

SLES12-SP3-Updates | SUSE-SLE-SERVER-12-SP3-2018-89 | security | moderate | --- | needed | Security update for perl-XML-LibXML

SLES12-SP3-Updates | SUSE-SLE-SERVER-12-SP3-2018-90 | recommended | low | --- | needed | Recommended update for lvm2

Found 37 applicable patches:

37 patches needed (18 security patches)

使用相应的表头可以很好地组织输出。你可以轻松地找出并根据情况计划你的补丁更新。我们能看到在我们的系统中,37 个可用补丁中有 18 个是安全补丁,需要被高优先级应用!

你可以通过发出 zypper patch 命令安装所有需要的补丁。

如何使用 zypper 更新包

要使用 zypper 更新包,使用 update 或 up 子命令后接包名。在上述列出的更新命令中,我们知道在我们的服务器上 rsync 包更新可用。让我们现在来更新它吧!

root@kerneltalks # zypper update rsync

Refreshing service 'SMT-http_smt-ec2_susecloud_net'.

Refreshing service 'cloud_update'.

Loading repository data...

Reading installed packages...

Resolving package dependencies...

The following package is going to be upgraded:

rsync

1 package to upgrade.

Overall download size: 325.2 KiB. Already cached: 0 B. After the operation, additional 64.0 B will be used.

Continue? [y/n/...? shows all options] (y): y

Retrieving package rsync-3.1.0-13.10.1.x86_64 (1/1), 325.2 KiB (625.5 KiB unpacked)

Retrieving: rsync-3.1.0-13.10.1.x86_64.rpm .......................................................................................................................[done]

Checking for file conflicts: .....................................................................................................................................[done]

(1/1) Installing: rsync-3.1.0-13.10.1.x86_64 .....................................................................................................................[done]

在 Suse Linux 上使用 zypper 查找包

如果你不确定包的全名也不要担心。你可以使用 zypper 附带的 se 或 search 子命令并提供查找字符串来查找包。

root@kerneltalks # zypper se lvm

Refreshing service 'SMT-http_smt-ec2_susecloud_net'.

Refreshing service 'cloud_update'.

Loading repository data...

Reading installed packages...

S | Name | Summary | Type

---|---------------|------------------------------|-----------

| libLLVM | Libraries for LLVM | package

| libLLVM-32bit | Libraries for LLVM | package

| llvm | Low Level Virtual Machine | package

| llvm-devel | Header Files for LLVM | package

| lvm2 | Logical Volume Manager Tools | srcpackage

i+ | lvm2 | Logical Volume Manager Tools | package

| lvm2-devel | Development files for LVM2 | package

在上述示例中我们查找了 lvm 字符串并得到了如上输出列表。你能在 zypper install/remove/update 命令中使用 Name 字段的名字。

使用 zypper 检查已安装包信息

你能够使用 zypper 检查已安装包的详细信息。info 或 if 子命令将列出已安装包的信息。它也可以显示未安装包的详细信息,在该情况下,Installed 参数将返回 No 值。

root@kerneltalks # zypper info rsync

Refreshing service 'SMT-http_smt-ec2_susecloud_net'.

Refreshing service 'cloud_update'.

Loading repository data...

Reading installed packages...

Information for package rsync:

------------------------------

Repository : SLES12-SP3-Updates

Name : rsync

Version : 3.1.0-13.10.1

Arch : x86_64

Vendor : SUSE LLC

Support Level : Level 3

Installed Size : 625.5 KiB

Installed : Yes

Status : up-to-date

Source package : rsync-3.1.0-13.10.1.src

Summary : Versatile tool for fast incremental file transfer

Description :

Rsync is a fast and extraordinarily versatile file copying tool. It can copy

locally, to/from another host over any remote shell, or to/from a remote rsync

daemon. It offers a large number of options that control every aspect of its

behavior and permit very flexible specification of the set of files to be

copied. It is famous for its delta-transfer algorithm, which reduces the amount

of data sent over the network by sending only the differences between the

source files and the existing files in the destination. Rsync is widely used

for backups and mirroring and as an improved copy command for everyday use.

使用 zypper 列出仓库

使用 zypper 命令附带 lr 或 repos 子命令列出仓库。

root@kerneltalks # zypper lr

Refreshing service 'cloud_update'.

Repository priorities are without effect. All enabled repositories share the same priority.

# | Alias | Name | Enabled | GPG Check | Refresh

---|--------------------------------------------------------------------------------------|-------------------------------------------------------|---------|-----------|--------

1 | SMT-http_smt-ec2_susecloud_net:SLE-Module-Adv-Systems-Management12-Debuginfo-Pool | SLE-Module-Adv-Systems-Management12-Debuginfo-Pool | No | ---- | ----

2 | SMT-http_smt-ec2_susecloud_net:SLE-Module-Adv-Systems-Management12-Debuginfo-Updates | SLE-Module-Adv-Systems-Management12-Debuginfo-Updates | No | ---- | ----

3 | SMT-http_smt-ec2_susecloud_net:SLE-Module-Adv-Systems-Management12-Pool | SLE-Module-Adv-Systems-Management12-Pool | Yes | (r ) Yes | No

4 | SMT-http_smt-ec2_susecloud_net:SLE-Module-Adv-Systems-Management12-Updates | SLE-Module-Adv-Systems-Management12-Updates | Yes | (r ) Yes | Yes

5 | SMT-http_smt-ec2_susecloud_net:SLE-Module-Containers12-Debuginfo-Pool | SLE-Module-Containers12-Debuginfo-Pool | No | ---- | ----

6 | SMT-http_smt-ec2_susecloud_net:SLE-Module-Containers12-Debuginfo-Updates | SLE-Module-Containers12-Debuginfo-Updates | No | ---- | ----

此处你需要检查 enabled 列来确定哪些仓库是已被启用的而哪些没有。

在 Suse Linux 中使用 zypper 添加或移除仓库

要添加仓库你需要仓库或 .repo 文件的 URI,否则你会遇到如下错误。

root@kerneltalks # zypper addrepo -c SLES12-SP3-Updates

If only one argument is used, it must be a URI pointing to a .repo file.

使用 URI,你可以像如下方式添加仓库:

root@kerneltalks # zypper addrepo -c http://smt-ec2.susecloud.net/repo/SUSE/Products/SLE-SDK/12-SP3/x86_64/product?credentials=SMT-http_smt-ec2_susecloud_net SLE-SDK12-SP3-Pool

Adding repository 'SLE-SDK12-SP3-Pool' ...........................................................................................................................[done]

Repository 'SLE-SDK12-SP3-Pool' successfully added

URI : http://smt-ec2.susecloud.net/repo/SUSE/Products/SLE-SDK/12-SP3/x86_64/product?credentials=SMT-http_smt-ec2_susecloud_net

Enabled : Yes

GPG Check : Yes

Autorefresh : No

Priority : 99 (default priority)

Repository priorities are without effect. All enabled repositories share the same priority.

在 Suse 中使用附带 addrepo 或 ar 子命令的 zypper 命令添加仓库,后接 URI 以及你需要提供一个别名。

要在 Suse 中移除一个仓库,使用附带 removerepo 或 rr 子命令的 zypper 命令。

root@kerneltalks # zypper removerepo nVidia-Driver-SLE12-SP3

Removing repository 'nVidia-Driver-SLE12-SP3' ....................................................................................................................[done]

Repository 'nVidia-Driver-SLE12-SP3' has been removed.

清除 zypper 本地缓存

使用 zypper clean 命令清除 zypper 本地缓存。

root@kerneltalks # zypper clean

All repositories have been cleaned up.

本文由 LCTT 原创编译,Linux中国 荣誉推出

linux permit用法,技术|12 条实用的 zypper 命令范例相关推荐

  1. 12 条实用的 zypper 命令范例

    zypper 是 Suse Linux 系统的包和补丁管理器,你可以根据下面的 12 条附带输出示例的实用范例来学习 zypper 命令的使用. Suse Linux 使用 zypper 进行包管理, ...

  2. linux+查看磁带信息,15 条实用 Linux/Unix 磁带管理命令

    导读 磁带设备应只用于定期的文件归档或将数据从一台服务器传送至另一台.通常磁带设备与 Unix 机器连接,用 mt 或 mtx 控制.强烈建议您将所有的数据同时备份到磁盘(也许是云中)和磁带设备中. ...

  3. linux中shuf命令用法,技术|给初学者看的 shuf 命令教程

    shuf 命令用于在类 Unix 操作系统中生成随机排列.使用 shuf 命令,我们可以随机打乱给定输入文件的行.shuf 命令是 GNU Coreutils 的一部分,因此你不必担心安装问题.在这个 ...

  4. 【网站建设】Linux上安装MySQL - 12条命令搞定MySql

    从零开始安装mysql数据库 : 按照该顺序执行 :  a. 查看是否安装有mysql:yum list installed mysql*, 如果有先卸载掉, 然后在进行安装; b. 安装mysql客 ...

  5. 亲爱的,我是一条Linux运维技术学习路径呀。

    根据我的经验,人在年轻时,最头疼的一件事就是决定自己这一生要做什么.在这方面,我倒没有什么具体的建议:干什么都可以,但最好不要写小说,这是和我抢饭碗.总而言之,干什么都是好的:但要干出个样子来,这才是 ...

  6. 【NLP技术应用】工业界求解NER问题的12条黄金法则

    众所周知,命名实体识别(Named Entity Recognition,NER)是一项基础而又重要的NLP词法分析任务,也往往作为信息抽取.问答系统.机器翻译等方向的或显式或隐式的基础任务. 在很多 ...

  7. 在ThoughtWorks工作12年的技术主管,所总结的12条技术人经验

    原文: 12 years, 12 lessons working at ThoughtWorks 作者: Patrick,ThoughtWorks的技术主管兼敏捷顾问 编译: 孙薇 本文作者在Thou ...

  8. 学习笔记:SpringCloud 微服务技术栈_实用篇①_基础知识

    若文章内容或图片失效,请留言反馈.部分素材来自网络,若不小心影响到您的利益,请联系博主删除. 前言 学习视频链接 SpringCloud + RabbitMQ + Docker + Redis + 搜 ...

  9. linux awk语法格式,Awk是什么?一文带运维小白快速掌握Linux Awk用法

    原标题:Awk是什么?一文带运维小白快速掌握Linux Awk用法 作者:a8 Awk.sed与grep,俗称Linux下的三剑客,它们之间有很多相似点,但是同样也各有各的特色,相似的地方是它们都可以 ...

最新文章

  1. 【ACM】杭电OJ 1076
  2. 美国科学院报告《无止境的前沿:科学的未来75年》
  3. Camel中的几个重要概念之Routes, RouteBuilders 和 Java DSL
  4. 四五六年级计算机教学计划,五六年级信息技术教学计划
  5. datavideo切换台说明书_巴掌大三轴稳定器,稳过微云台,试试飞宇VLOGPocket2
  6. c语言字符串未初始化strcat,C语言中字符串常用函数strcat与strcpy的用法介绍
  7. PCB常用度量衡单位
  8. 中label换行问题_如何巧妙处理 Git 多平台换行符问题(LF or CRLF)
  9. Android系统音量范围0-100,步进值5(十三)
  10. ocp007 题库解析(1-15)
  11. pyltp实现句法分析并画出句法图
  12. android wifi热点默认名称,Android 修改WiFi热点的默认SSID和密码
  13. 没用东西全部清掉_如何把电脑上无用的东西清理掉,在哪下载
  14. H5 的直播协议和视频监控方案
  15. 如何在被伽卡他卡教师端控制时解除控制
  16. 抖音运营技巧都有哪些?如何让爆粉?
  17. UI5-文档-4.5-Controllers
  18. C#笔试题面试题锦集
  19. python 爬虫 Form Data爬取穷游网的数据
  20. 快速解决Android编译报错 : Manifest merger failed with multiple errors, see logs

热门文章

  1. STM32 基础系列教程 11 – ADC 轮询
  2. 10-Flutter移动电商实战-使用FlutterSwiper制作轮播效果
  3. 安卓开发必备知识体系:安卓篇
  4. BZOJ 3489: A simple rmq problem(K-D Tree)
  5. MySQL自学2018/05/02-数据类型
  6. 网络爬虫(2)-- Java爬虫框架
  7. 如何在ASP.NET中用OWC绘制图表
  8. 性能之外:LSI 6Gb/s SAS RAID渠道先行
  9. ESP32移植wolfssl方法
  10. csrf攻击防御 php,Yii2.0防御csrf攻击方法