SUSE Linux – Zypper 命令示例

什么是zypper?

zypper 是原生 ZYpp 包管理器的命令行界面。zypper 主要存在于 SLES(SUSE Linux Enterprise Server)和 openSUSE 发行版中。zypper 用于安装、删除、更新和查询软件包。

软件管理

安装包: zypper install packagename


# zypper install htop
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
  htop

1 new package to install.
Overall download size: 129.9 KiB. Already cached: 0 B. After the operation,
additional 296.0 KiB will be used.
Continue? [y/n/v/...? shows all options] (y): y
Retrieving package htop-3.0.5-lp152.4.4.1.x86_64
                                           (1/1), 129.9 KiB (296.0 KiB unpacked)
Retrieving: htop-3.0.5-lp152.4.4.1.x86_64.rpm ............................[done]

Checking for file conflicts: .............................................[done]
(1/1) Installing: htop-3.0.5-lp152.4.4.1.x86_64 ..........................[done]
 

已通过指定“安装”选项安装了“htop”包。您可以使用相同命令“zypper in htop”的缩短版本。

删除包: zypper remove packagename


# zypper remove htop
Reading installed packages...
Resolving package dependencies...

The following package is going to be REMOVED:
  htop

1 package to remove.
After the operation, 296.0 KiB will be freed.
Continue? [y/n/v/...? shows all options] (y): y
(1/1) Removing htop-3.0.5-lp152.4.4.1.x86_64 .............................[done]
 

上面的“删除”选项删除指定的包。同样,此命令可以缩写为“zypper rm htop”。

显示存储库:zypper 存储库


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

#  | Alias                     | Name                               | Enabled | GPG Check | Refresh
---+---------------------------+------------------------------------+---------+-----------+--------
 1 | openSUSE-Leap-15.2-1      | openSUSE-Leap-15.2-1               | No      | ----      | ----
 2 | repo-debug                | Debug Repository                   | No      | ----      | ----
 3 | repo-debug-non-oss        | Debug Repository (Non-OSS)         | No      | ----      | ----
 4 | repo-debug-update         | Update Repository (Debug)          | No      | ----      | ----
 5 | repo-debug-update-non-oss | Update Repository (Debug, Non-OSS) | No      | ----      | ----
 6 | repo-non-oss              | Non-OSS Repository                 | Yes     | (r ) Yes  | Yes
 7 | repo-oss                  | Main Repository                    | Yes     | (r ) Yes  | Yes
 8 | repo-source               | Source Repository                  | No      | ----      | ----
 9 | repo-source-non-oss       | Source Repository (Non-OSS)        | No      | ----      | ----
10 | repo-update               | Main Update Repository             | Yes     | (r ) Yes  | Yes
11 | repo-update-non-oss       | Update Repository (Non-Oss)        | Yes     | (r ) Yes  | Yes
 

列出可用更新:zypper list-updates


leap:~ # zypper list-updates
Loading repository data...
Reading installed packages...
S | Repository             | Name                                 | Current Version                          | Available Version                        | Arch
--+------------------------+--------------------------------------+------------------------------------------+------------------------------------------+-------
v | Main Update Repository | ImageMagick                          | 7.0.7.34-lp152.12.12.1                   | 7.0.7.34-lp152.12.15.1                   | x86_64
v | Main Update Repository | ImageMagick-config-7-SUSE            | 7.0.7.34-lp152.12.12.1                   | 7.0.7.34-lp152.12.15.1                   | x86_64
v | Main Update Repository | MozillaFirefox                       | 78.9.0-lp152.2.52.1                      | 78.10.0-lp152.2.55.1                     | x86_64
v | Main Update Repository | MozillaFirefox-translations-common   | 78.9.0-lp152.2.52.1                      | 78.10.0-lp152.2.55.1                     | x86_64
v | Main Update Repository | NetworkManager                       | 1.22.10-lp152.2.3.1                      | 1.22.10-lp152.2.6.1                      | x86_64
v | Main Update Repository | NetworkManager-lang                  | 1.22.10-lp152.2.3.1                      | 1.22.10-lp152.2.6.1                      | noarch
v | Main Update Repository | bash                                 | 4.4-lp152.11.80                          | 4.4-lp152.12.3.1                         | x86_64
 

上面的输出显示当前安装的软件及其版本号以及该软件的最新可用版本。上面的输出示例已被缩短,因为完整列表的大小相当可观。

更新包:zypper 更新


leap:~ # zypper update
Loading repository data...
Reading installed packages...

The following 5 NEW packages are going to be installed:
  grub2-x86_64-efi kernel-default-5.3.18-lp152.72.1 libdav1d3 libwoff2common1_0_2 libwoff2dec1_0_2

The following 161 packages are going to be upgraded:
  ImageMagick ImageMagick-config-7-SUSE MozillaFirefox MozillaFirefox-translations-common NetworkManager NetworkManager-lang bash bash-doc bash-lang bind-utils
  cifs-utils cups cups-client cups-config dhcp dhcp-client dracut e2fsprogs ebtables gdk-pixbuf-loader-rsvg gnome-session gnome-session-core
  gnome-session-default-session gnome-session-lang gnome-session-wayland gnome-shell-search-provider-nautilus gpgme grub2 grub2-i386-pc grub2-snapper-plugin
  grub2-systemd-sleep-plugin gzip irqbalance libIlmImf-2_2-23 libMagickCore-7_Q16HDRI6 libMagickWand-7_Q16HDRI6 libavcodec58 libavfilter7 libavformat58 libavresample4
  libavutil56 libbind9-1600 libcap2 libcom_err2 libcups2 libcupscgi1 libcupsimage2 libcupsmime1 libcupsppdc1 libdcerpc-binding0 libdcerpc0 libdns1605 libext2fs2
  libgif7 libgnomesu libgnomesu-lang libgnomesu0 libgpgme11 libgpgmepp6 libhogweed4 libirs1601 libisc1606 libisccc1600 libisccfg1600 libjavascriptcoregtk-4_0-18
  libkyotocabinet16 libldap-2_4-2 libldap-data libmpfr6 libnautilus-extension1 libndr-krb5pac0 libndr-nbt0 libndr-standard0 libndr0 libnetapi0 libnettle6 libnm0
  libns1604 libnuma1 libpostproc55 libprocps7 libpulse-mainloop-glib0 libpulse0 libreadline7 librsvg-2-2 librsvg-lang libruby2_5-2_5 libsamba-credentials0
  libsamba-errors0 libsamba-hostconfig0 libsamba-passdb0 libsamba-policy0-python3 libsamba-util0 libsamdb0 libsmbclient0 libsmbconf0 libsmbldap2 libsolv-tools
  libswresample3 libswscale5 libsystemd0 libtevent-util0 libudev1 libva-drm2 libva-glx2 libva-x11-2 libva2 libwbclient0 libwebkit2gtk-4_0-37 libwebkit2gtk3-lang
  libzypp mdadm nautilus nautilus-lang numactl openldap2-client openslp procps pulseaudio pulseaudio-bash-completion pulseaudio-gdm-hooks pulseaudio-lang
  pulseaudio-module-bluetooth pulseaudio-module-gsettings pulseaudio-module-x11 pulseaudio-module-zeroconf pulseaudio-utils python3-bind python3-solv qemu-guest-agent
  readline-doc rsvg-thumbnailer rsyslog ruby-solv ruby2.5 ruby2.5-stdlib samba samba-client samba-libs samba-libs-python3 samba-python3 shim sudo systemd
  systemd-bash-completion systemd-presets-common-SUSE systemd-sysvinit tcsh tcsh-lang typelib-1_0-JavaScriptCore-4_0 typelib-1_0-NM-1_0 typelib-1_0-Rsvg-2_0
  typelib-1_0-WebKit2-4_0 udev webkit2gtk-4_0-injected-bundles wpa_supplicant xorg-x11-server xorg-x11-server-extra xorg-x11-server-wayland yast2-samba-client
  yast2-security

The following 2 packages require a system reboot:
  kernel-default-5.3.18-lp152.72.1 systemd

161 packages to upgrade, 5 new.
Overall download size: 131.0 MiB. Already cached: 95.8 MiB. After the operation, additional 393.2 MiB will be used.

    Note: System reboot required.
Continue? [y/n/v/...? shows all options] (y): 
 

上面的“ zypper update ”命令将升级所有包。您需要确认“ y ”才能继续升级。更新进度将显示在您的控制台上(请参阅下面的输出示例:


In cache libdav1d3-0.5.2-lp152.1.4.x86_64.rpm                                                                                   (1/166), 318.7 KiB (869.7 KiB unpacked)
Retrieving package libwoff2common1_0_2-1.0.2-lp152.1.3.x86_64                                                                   (2/166),  12.5 KiB ( 11.0 KiB unpacked)
Retrieving: libwoff2common1_0_2-1.0.2-lp152.1.3.x86_64.rpm ..........................................................................................[done (6.6 KiB/s)]
Retrieving package libwoff2dec1_0_2-1.0.2-lp152.1.3.x86_64                                                                      (3/166),  25.6 KiB ( 42.1 KiB unpacked)
Retrieving: libwoff2dec1_0_2-1.0.2-lp152.1.3.x86_64.rpm .........................................................................................................[done]
Retrieving package dhcp-4.3.5-lp152.8.3.1.x86_64                                                                                (4/166), 712.9 KiB (  1.8 MiB unpacked)
Retrieving delta: ./x86_64/dhcp-4.3.5-lp152.7.4_lp152.8.3.1.x86_64.drpm, 25.5 KiB
Retrieving: dhcp-4.3.5-lp152.7.4_lp152.8.3.1.x86_64.drpm ........................................................................................................[done]
Applying delta: ./dhcp-4.3.5-lp152.7.4_lp152.8.3.1.x86_64.drpm ..................................................................................................[done]
Retrieving package libIlmImf-2_2-23-2.2.1-lp152.7.14.1.x86_64                                                                   (5/166), 543.7 KiB (  2.8 MiB unpacked)
.......
.......
Executing %posttrans scripts ....................................................................................................................................[done]
There are running programs which still use files and libraries deleted or updated by recent upgrades. They should be restarted to benefit from the latest updates. Run 'zypper ps -s' to list these programs.
 
Core libraries or services have been updated.
Reboot is required to ensure that your system benefits from these updates.
 

以上只是所产生的输出的一小部分的摘录。

现在,如果我们重新运行zypper list-updates命令,我们应该看到所有包现在都是最新的:


# zypper list-updates
Loading repository data...
Reading installed packages...
No updates found.
 

检查已安装的软件包

以下是“ zypper search ”命令的摘录。


# zypper search
Loading repository data...
Reading installed packages...

S  | Name                                                       | Summary                                                                                  | Type
---+------------------------------------------------------------+------------------------------------------------------------------------------------------+-----------
   | ASL-doc                                                    | API documentation for the Advanced Simulation Library                                    | package
   | AdobeICCProfiles                                           | Adobe ICC Profiles                                                                       | package
   | AppCSXCAD                                                  | Minimal GUI Application using the QCSXCAD library                                        | package
i  | AppStream                                                  | Utilities to generate, maintain and access the AppStream Xapian database                 | package
   | AppStream-devel                                            | Header files for AppStream development                                                   | package
   | AppStream-doc                                              | Documentation for AppStream                                                              | package
i  | AppStream-lang                                             | Translations for package AppStream                                                       | package
   | AusweisApp2                                                | Official authentication app for German ID cards and residence permits                    | package
 

在上面的例子中,我们发出了“ zypper search ”命令。这将列出所有包信息。输出以表格格式显示。第一列列出状态“ S ”。如果出现“ i ”,则表示该软件包已安装。“ v ”表示已安装另一个版本,空白表示尚未安装该软件包(以上选项均未安装)。以下列是不言自明的,指示名称、摘要类型等。

可以想象,大多数系统上都有很多包,因此输出将相当可观。一个更有用的选项是提供您要查询的模式或包的名称:


# zypper search htop
Loading repository data...
Reading installed packages...

S  | Name | Summary                                           | Type
---+------+---------------------------------------------------+-----------
i+ | htop | An Interactive text-mode Process Viewer for Linux | package
   | htop | An Interactive text-mode Process Viewer for Linux | srcpackage
 

从上面的例子我们可以看到已经安装了包“htop”。

获得有关 zypper 的帮助

有关可以传递给 zypper 命令的所有可能参数和选项的更多信息,您可以发出“ zypper --help ”命令或使用“ man zypper ”命令查阅“手册页” :


# zypper --help

Usage:

    zypper [--GLOBAL-OPTIONS] [--COMMAND-OPTIONS] [ARGUMENTS]
    zypper  [--COMMAND-OPTIONS] [ARGUMENTS]

Global Options:

    --help, -h              Help.
    --version, -V           Output the version number.
    --promptids             Output a list of zypper's user prompts.
    --config, -c      Use specified config file instead of the default.
    --userdata      User defined transaction id used in history and plugins.
    --quiet, -q             Suppress normal output, print only error messages.
    --verbose, -v           Increase verbosity.
    --color
    --no-color              Whether to use colors in output if tty supports it.
    --no-abbrev, -A         Do not abbreviate text in tables. Default: false
    --table-style, -s 
                            Table style (0-11).
    --non-interactive, -n   Do not ask anything, use default answers automatically. Default: false
    --non-interactive-include-reboot-patches
                            Do not treat patches as interactive, which have the rebootSuggested-flag
                            set. Default: false
    --xmlout, -x            Switch to XML output.
    --ignore-unknown, -i    Ignore unknown packages. Default: false
    --terse, -t             Terse output for machine consumption. Implies --no-abbrev and
                            --no-color.


    --reposd-dir, -D <DIR>  Use alternative repository definition file directory.
    --cache-dir, -C <DIR>   Use alternative directory for all caches.
    --raw-cache-dir <DIR>   Use alternative raw meta-data cache directory.
    --solv-cache-dir <DIR>  Use alternative solv file cache directory.
    --pkg-cache-dir <DIR>   Use alternative package cache directory.

  Repository Options

    --no-gpg-checks         Ignore GPG check failures and continue. Default: false
    --gpg-auto-import-keys  Automatically trust and import new repository signing keys.
    --plus-repo, -p    Use an additional repository.
    --plus-content     Additionally use disabled repositories providing a specific keyword. Try
                            '--plus-content debug' to enable repos indicating to provide debug
                            packages.
    --disable-repositories  Do not read meta-data from repositories.
    --no-refresh            Do not refresh the repositories.
    --no-cd                 Ignore CD/DVD repositories.
    --no-remote             Ignore remote repositories.
    --releasever            Set the value of $releasever in all .repo files (default: distribution
                            version)

  Target Options

    --root, -R <DIR>        Operate on a different root directory.
    --installroot <DIR>     Operate on a different root directory, but share repositories with the
                            host.
    --disable-system-resolvables
                            Do not read installed packages.

Commands:

      help, ?               Print zypper help
      shell, sh             Accept multiple commands at once.

  Repository Management:

      repos, lr             List all defined repositories.
      addrepo, ar           Add a new repository.
      removerepo, rr        Remove specified repository.
      renamerepo, nr        Rename specified repository.
      modifyrepo, mr        Modify specified repository.
      refresh, ref          Refresh all repositories.
      clean, cc             Clean local caches.

  Service Management:

      services, ls          List all defined services.
      addservice, as        Add a new service.
      modifyservice, ms     Modify specified service.
      removeservice, rs     Remove specified service.
      refresh-services, refs
                            Refresh all services.

  Software Management:

      install, in           Install packages.
      remove, rm            Remove packages.
      verify, ve            Verify integrity of package dependencies.
      source-install, si    Install source packages and their build dependencies.
      install-new-recommends, inr
                            Install newly added packages recommended by installed packages.

  Update Management:

      update, up            Update installed packages with newer versions.
      list-updates, lu      List available updates.
      patch                 Install needed patches.
      list-patches, lp      List available patches.
      dist-upgrade, dup     Perform a distribution upgrade.
      patch-check, pchk     Check for patches.

  Querying:

      search, se            Search for packages matching a pattern.
      info, if              Show full information for specified packages.
      patch-info            Show full information for specified patches.
      pattern-info          Show full information for specified patterns.
      product-info          Show full information for specified products.
      patches, pch          List all available patches.
      packages, pa          List all available packages.
      patterns, pt          List all available patterns.
      products, pd          List all available products.
      what-provides, wp     List packages providing specified capability.

  Package Locks:

      addlock, al           Add a package lock.
      removelock, rl        Remove a package lock.
      locks, ll             List current package locks.
      cleanlocks, cl        Remove useless locks.

  Locale Management:

      locales, lloc         List requested locales (languages codes).
      addlocale, aloc       Add locale(s) to requested locales.
      removelocale, rloc    Remove locale(s) from requested locales.

  Other Commands:

      versioncmp, vcmp      Compare two version strings.
      targetos, tos         Print the target operating system ID string.
      licenses              Print report about licenses and EULAs of installed packages.
      download              Download rpms specified on the commandline to a local directory.
      source-download       Download source rpms for all installed packages to a local directory.
      needs-rebooting       Check if the needs-reboot flag was set.
      ps                    List running processes which might still use files and libraries deleted
                            by recent upgrades.
      purge-kernels         Remove old kernels.

  Subcommands:

      subcommand            Lists available subcommands.
      appstream-cache       
      lifecycle             
      log                   

Type 'zypper help' to get command-specific help.

Zypper 是 SuSE Linux 中的命令行界面,用于安装、更新、删除软件、管理存储库、执行各种查询等等。在本文中,我们将讨论 zypper 命令的不同示例。

句法 :

# zypper [--global-opts] <command> [--command-opts] [command-arguments]

示例:1 列出可用的全局选项和命令。

打开终端,输入 Zypper 命令并回车,它将显示所有可以在 zypper 中使用的全局选项和命令。

# zypper
localhost:~ # zypper

用法:

    zypper [--全局选项] <命令> [--命令选项] [参数]
    zypper <子命令> [--命令选项] [参数]

全局选项:

    --help, -h              帮助。
    --version, -V           输出版本号。
    --promptids             输出 zypper 的用户提示列表。
    --config, -c <文件>     使用指定而非默认的配置文件。
    --userdata <字符串>     用户自定义的用于历史和插件中的事务 ID。
    --quiet, -q             压制正常输出,仅打印错误消息。
    --verbose, -v           增加消息的详细程度(调试模式)。
    --color
    --no-color              若 tty 支持是否使用有颜色输出。
    --no-abbrev, -A         在表格中不要缩写文本。 Default: false
    --table-style, -s <整数>
                            表格样式 (0-11).
    --non-interactive, -n   不询问任何选择,自动使用默认回复。 Default: false
    --non-interactive-include-reboot-patches
                            不把那些设置了"建议重启"旗标
                            的补丁视为可与用户交互的。 Default: false
    --xmlout, -x            切换到 XML 输出。
    --ignore-unknown, -i    忽略未知软件包。 Default: false
    --terse, -t             供程序阅读的简洁输出。这意味着 —no-abbrev 和
                            —no-color。


    --reposd-dir, -D <文件夹>
                            使用另一个软件源定义文件文件夹。
    --cache-dir, -C <文件夹>
                            为全部缓存使用另一个文件夹。
    --raw-cache-dir <文件夹>
                            使用另一个原始元数据缓存文件夹。
    --solv-cache-dir <文件夹>
                            使用另一个 solv 文件缓存文件夹。
    --pkg-cache-dir <文件夹>
                            使用另一个软件包缓存文件夹。

  软件源选项

    --no-gpg-checks         忽略失败的 GPG 校验并继续。 Default: false
    --gpg-auto-import-keys  自动信任并导入新软件源签名密钥。
    --plus-repo, -p <URI>   使用一个附加软件源。
    --plus-content <标签>   也使用提供指定关键字的已禁用软件源。可尝试使用
                            ‘--plus-content debug’
                            来临时启用表明其提供了侦错软件包的软件源。
    --disable-repositories  不从软件源读取元数据。
    --no-refresh            不刷新软件源。
    --no-cd                 忽略 CD/DVD 软件源。
    --no-remote             忽略远程软件源。
    --releasever            设置全部 .repo 文件中 $releasever
                            的值(默认:发行版版本号)

  目标选项

    --root, -R <文件夹>     在一个不同的根目录下操作。
    --installroot <文件夹>  在一个不同的根目录下操作,但与主机共享软件源。
    --disable-system-resolvables
                            不读取已安装软件包。

命令:

      help, ?               打印 zypper 帮助
      shell, sh             一次性接受多个命令。

  软件源管理:

      repos, lr             列出全部已定义的软件源。
      addrepo, ar           添加一个新软件源。
      removerepo, rr        移除指定软件源。
      renamerepo, nr        重命名指定软件源。
      modifyrepo, mr        修改指定软件源。
      refresh, ref          刷新全部软件源。
      clean, cc             清理本地缓存。

  服务管理:

      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        移除无用的锁定。

  区域管理:

      locales, lloc         列出所请求区域 (语言代码)。
      addlocale, aloc       添加区域到所请求区域。
      removelocale, rloc    从所请求区域中移除区域。

  其它命令:

      versioncmp, vcmp      比较两个版本字符串。
      targetos, tos         打印目标操作系统 ID 字符串。
      licenses              打印已安装软件包的许可证和最终用户协议的汇总报告。
      download              下载通过命令行指定的 RPM 到本地文件夹。
      source-download       下载全部已安装软件包的源代码 RPM 到一个本地文件夹。
      needs-rebooting       检查需要重启旗标是否设置。
      ps
                            列出可能仍使用着被最近升级删除的文件和函数库的运行中进程。
      purge-kernels         移除旧内核。

  子命令:

      subcommand            列出可用子命令。
      appstream-cache       <没有 "zypper-appstream-cache" 的手册页入口>
      lifecycl

示例:2 获取特定 zypper 命令的帮助。

语法:zypper help [命令]

localhost:~ # zypper help remove
remove (rm) [选项] <功能> ...

移除具有指定功能的软件包。功能的定义为"名称[.架构][操作符 <版本>]",操作符为 <,
<=, =, >=, > 其中之一。

  命令选项:

-t, --type <TYPE>           软件包类型 (package, patch, pattern, product)。
-n, --name                  单纯通过名称而非功能选择软件包。 Default: false
-C, --capability            仅通过功能选取软件包。 Default: false
    --details               显示详细安装摘要。 Default: false
-r, --repo <别名|#|URI>     仅限于指定软件源。
-y, --no-confirm            无需用户交互。全局选项 --non-interactive 的别名。
                            Default: false
-D, --dry-run               不作修改,仅汇报将进行的修改。 文件冲突检查只有与
                            ‘--download-only’ 一起使用时执行得才有意义。
                            Default: false
-u, --clean-deps            自动移除不需要的依赖关系。
-U, --no-clean-deps         不自动移除不需要的依赖关系。

  解算器选项

    --debug-solver          创建依赖关系解算器试例以供侦错。
    --force-resolution
                            强迫解算器找出解决方案(即使是激进的方案)而不要询问。
-R, --no-force-resolution   不强迫解算器找出解决方案,允许它提问。
    --solver-focus <模式>   结算作业时设置结算器一般属性。

示例:3 打开 Zypper Shell 或会话

linux-xa3t:~ # zypper sh
zypper>

or

linux-xa3t:~ # zypper shell
zypper>

示例:4 列出定义的存储库

linux-xa3t:~ # zypper repos

zypper-repos

或者

linux-xa3t:~ # zypper lr

4.1) 在表中列出 Repos URI。

zypper-repos-uri

4.2) 按优先级列出 Repos

linux-xa3t:~ # zypper lr -p

zypper-repos-优先级

示例:5 刷新存储库。

localhost:~ # zypper refresh
软件源 'Update repository of openSUSE Backports' 是最新的。
软件源 'Non-OSS Repository' 是最新的。
软件源 'Main Repository' 是最新的。
软件源 'Update repository with updates from SUSE Linux Enterprise 15' 是最新的。
软件源 'Main Update Repository' 是最新的。
软件源 'Update Repository (Non-Oss)' 是最新的。
全部软件源均已刷新。

示例:6 修改 Zypper 存储库

zypper 存储库可以通过别名、数字或 URI,或通过“–all、–remote、–local、–medium-type”聚合选项进行修改。

linux-xa3t:~ # zypper mr -d 6                 #disable repo #6
linux-xa3t:~ # zypper mr -rk -p 70 upd #enable autorefresh and rpm files ‘caching’ for ‘upd’ repo and set its priority to 70
linux-xa3t:~ # zypper mr -Ka               #disable rpm files caching for all repos
linux-xa3t:~ # zypper mr -kt               #enable rpm files caching for remote repos

示例:7 添加存储库

语法:zypper addrepo OR zypper ar <repo url and alias>

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 <Repo Name> <Alias>

或者

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 <Package-Name> OR zypper in <Package Name>

linux-xa3t:~ # zypper install vlc

示例:10 删除包

语法:zypper remove <Package-Name> 或 zypper rm <Package-Name>

linux-xa3t:~ # zypper remove sqlite

示例:11 导出和导入存储库

导出 Repos 的语法: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.

导入 Repos 的语法:

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

示例:12 更新包

语法:zypper update <Package-Name> 或 zypper up <Package-Name>

linux-xa3t:~ # zypper update bash

示例:13 安装源码包

语法:zypper source-install <source-package> 或 zypper si <source-package>

linux-xa3t:~ # zypper source-install zypper

示例:14 仅安装构建依赖项

example:13 中的命令将安装和构建指定包的依赖项。如果要安装源包,请使用选项-D

# zypper source-install -D package_name

要仅安装构建依赖项,请使用-d。

# zypper source-install -d package_name

不错,但是你忘记了“zypper ps”命令,这在更新一些包后非常有用🙂

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值