SUSE系统(suse12_sp5) zypper命令使用及zypper源配置

SUSE系统(suse12_sp5) zypper命令使用及zypper源配置Zypper 是一个开源的命令行软件包管理器 用于在 SUSELinux 和 openSUSE 操作系统上安装 更新 删除和管理软件包

大家好,欢迎来到IT知识分享网。

参考文献及技术网站链接:
1、https://en.opensuse.org/SDB:Zypper_usage 
suse的官方网站,本文大部分内容基本上都参考这个网站
2、https://en.opensuse.org/openSUSE:Libzypp_URIs
zypper配置文件中的软件仓库的书写格式大全

一.        Zypper

Zypper是一个开源的命令行软件包管理器,用于在SUSE Linux和openSUSE操作系统上安装、更新、删除和管理软件包。它可以从各种来源(如官方软件仓库、第三方软件仓库、本地目录等)获取软件包,并提供了丰富的命令行选项和功能,使用户能够轻松地管理软件包和依赖关系。Zypper也支持自动依赖关系解决和冲突解决,以确保软件包之间的兼容性。

Zypper是OpenSUSE和企业版SUSE中软件包管理器ZYpp的命令行接口,主要用于管理软件包。以下是一些常用的zypper命令:

  1. 安装包:zypper install <package_name>
  2. 更新包:zypper update <package_name> 或 zypper update
  3. 删除包:zypper remove <package_name>
  4. 查询包:zypper search <package_name>
  5. 显示已安装包列表:zypper se | grep installed
  6. 显示可更新包列表:zypper list-updates
  7. 显示所有仓库:zypper lr
  8. 添加仓库:zypper ar <url>
  9. 删除仓库:zypper ar -d <repo_name>
  10. 启用仓库:zypper ar -e <repo_name>
  11. 禁用仓库:zypper ar -d <repo_name>

这些命令可以在终端中执行,根据需要选择相应的命令进行操作。

二.        语法

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

 三.        参数

Zypper命令的参数可以用于执行各种操作,以下是一些常用的参数:

  • -h 或 –help:显示帮助信息。
  • -v 或 –verbose:显示详细信息,包括每个安装/删除操作的详细输出。
  • -q 或 –quiet:减少输出,仅显示错误信息。
  • -p 或 –plus-repo:添加额外的软件源。
  • -d 或 –disable-repositories:不从安装源读取元数据。
  • -r 或 –rug-compatible:开启与rug的兼容。
  • -n 或 –non-interactive:自动使用默认的回复,不询问任何问题。
  • -x 或 –xmlout:切换到XML输出。
  • –cache-dir:使用其他的元数据缓存数据库目录。
  • –raw-cache-dir:使用其他的原始元数据缓存目录。
  • –reposd-dir:使用其他的安装源定义文件目录。
  • –root:在不同的根目录下操作。
  • –disable-system-sources:不读取系统安装的可解析项。

这些参数可以在命令行中组合使用,以实现不同的功能。例如,使用 zypper install <package_name> 可以安装一个指定的软件包,而 zypper update 可以更新所有已安装的软件包到最新版本。更多详细信息可以通过 man zypper 命令在终端中查看。

Zypper命令的参数可以用于执行各种操作:

  • install <package_name>:安装指定的软件包。
  • update <package_name>:更新指定的软件包到最新版本。
  • remove <package_name>:删除指定的软件包。
  • search <package_name>:查询指定的软件包是否存在。
  • list-updates:列出可用的软件包更新。
  • list-installed:列出已安装的软件包。
  • list-repositories:列出所有可用的软件仓库。
  • add-repository <url>:添加新的软件仓库。
  • remove-repository <repo_name>:删除现有的软件仓库。
  • enable-repository <repo_name>:启用现有的软件仓库。
  • disable-repository <repo_name>:禁用现有的软件仓库。

 四.        zypper源配置

        1.        配置本地源

系统环境:SLE-12-SP5-Server

显示所有仓库:zypper lr 

可以通过–help命令,查看有哪些参数

suse:~ # zypper lr --help repos (lr) [options] [repo] ... List all defined repositories. Command options: -e, --export <FILE.repo> Export all defined repositories as a single local .repo file. -a, --alias Show also repository alias. -n, --name Show also repository name. -u, --uri Show also base URI of repositories. -p, --priority Show also repository priority. -r, --refresh Show also the autorefresh flag. -d, --details Show more information like URI, priority, type. -s, --service Show also alias of parent service. -E, --show-enabled-only Show enabled repos only. -U, --sort-by-uri Sort the list by URI. -P, --sort-by-priority Sort the list by repository priority. -A, --sort-by-alias Sort the list by alias. -N, --sort-by-name Sort the list by name. 

zypper lr -u  查看原来的软件源并显示url

SUSE系统(suse12_sp5) zypper命令使用及zypper源配置

 zypper remove-repository <repo_name>/zypper rr <repo_name>:删除现有的软件仓库

suse:~ # zypper rr --help removerepo (rr) [options] <alias|#|URI> Remove repository specified by alias, number or URI. Command options: --loose-auth Ignore user authentication data in the URI. --loose-query Ignore query string in the URI. 

zypper rr 原来的软件源

SUSE系统(suse12_sp5) zypper命令使用及zypper源配置

 挂载光驱镜像到/mnt/iso目录:

 mount /dev/sr0 /mnt/iso

 SUSE系统(suse12_sp5) zypper命令使用及zypper源配置

 创建/iso目录

复制/mnt/iso里面所有内容到/iso目录下

suse:~ # mkdir /iso suse:~ # cp -a /mnt/iso/* /iso/

SUSE系统(suse12_sp5) zypper命令使用及zypper源配置

 添加仓库:zypper ar <url>

suse:~ # zypper ar --help addrepo (ar) [OPTIONS] <URI> <ALIAS> addrepo (ar) [OPTIONS] <FILE.repo> Add a repository to the system. The repository can be specified by its URI or can be read from specified .repo file (even remote). Command options: -r, --repo <FILE.repo> Just another means to specify a .repo file to read. -c, --check Probe URI. -C, --no-check Don't probe URI, probe later during refresh. -n, --name <NAME> Set a descriptive name for the repository. -e, --enable Enable a disabled repository. -d, --disable Disable the repository (but don't remove it). -f, --refresh Enable auto-refresh of the repository. -F, --no-refresh Disable auto-refresh of the repository. -p, --priority <INTEGER> Set priority of the repository. -k, --keep-packages Enable RPM files caching. -K, --no-keep-packages Disable RPM files caching. -g, --gpgcheck Enable GPG check for this repository. --gpgcheck-strict Enable strict GPG check for this repository. --gpgcheck-allow-unsigned Short hand for '--gpgcheck-allow-unsigned-repo --gpgcheck-allow-unsigned-package'. --gpgcheck-allow-unsigned-repo Enable GPG check but allow the repository metadata to be unsigned. --gpgcheck-allow-unsigned-package Enable GPG check but allow installing unsigned packages from this repository. -G, --no-gpgcheck Disable GPG check for this repository. --default-gpgcheck Use the global GPG check setting defined in /etc/zypp/zypp.conf. This is the default. -t, --type <TYPE> Type of repository (yast2, rpm-md, plaindir).

添加软件源并命名为iso1

zypper ar file:///iso iso1

SUSE系统(suse12_sp5) zypper命令使用及zypper源配置

 刷新软件源

zypper refresh(zypper ref)

suse:~ # zypper ref --help refresh (ref) [alias|#|URI] ... Refresh repositories specified by their alias, number or URI. If none are specified, all enabled repositories will be refreshed. Command options: -f, --force Force a complete refresh. -b, --force-build Force rebuild of the database. -d, --force-download Force download of raw metadata. -B, --build-only Only build the database, don't download metadata. -D, --download-only Only download raw metadata, don't build the database. -r, --repo <alias|#|URI> Refresh only specified repositories. -s, --services Refresh also services before refreshing repos.

SUSE系统(suse12_sp5) zypper命令使用及zypper源配置

验证是否配置成功

zypper lr -u

zypper in rzsz   安装上传下载工具

SUSE系统(suse12_sp5) zypper命令使用及zypper源配置

   

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/147250.html

(0)
上一篇 2025-04-08 20:20
下一篇 2025-04-08 20:26

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信