百度
360搜索
搜狗搜索

linux中如何配置yum源详细介绍

在 Linux 里,Yum(Yellowdog Updater, Modified)是极为常用的软件包管理器,借助配置 Yum 源,你能够从指定的软件仓库下载并安装软件包。下面为你详细介绍在不同 Linux 发行版中配置 Yum 源的方法。

CentOS/RHEL 7

  1. 备份原有 Yum 源配置文件

bash

  /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

  1. 下载新的 Yum 源配置文件
    以阿里云 Yum 源为例:

bash

   /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

若没有安装wget,可以先执行sudo yum install wget -y进行安装。
3. 清理并生成缓存
bash

 yum clean all

yum makecache

CentOS/RHEL 8

  1. 备份原有 Yum 源配置文件

bash

  /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

  1. 下载新的 Yum 源配置文件
    以阿里云 Yum 源为例:

bash

   /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

  1. 更新系统并清理生成缓存

bash

 dnf update 

dnf clean all

dnf makecache

手动配置 Yum 源

你也可以手动编辑 Yum 源配置文件,以下是一个示例:
bash

  /etc/yum.repos.d/myrepo.repo

在文件中添加以下内容:
plaintext

[myrepo]

name=My Custom Repository

baseurl=http://example.com/repo/

enabled=1

gpgcheck=0

  • [myrepo]:仓库的唯一标识符。
  • name:仓库的描述信息。
  • baseurl:软件包仓库的 URL 地址。
  • enabled:是否启用该仓库,1 表示启用,0 表示禁用。
  • gpgcheck:是否进行 GPG 签名检查,1 表示检查,0 表示不检查。

保存文件后,执行以下命令清理并生成缓存:
bash

 yum clean all

yum makecache




9123 yum clean all yum makecache

通过上述步骤,你就可以完成 Yum 源的配置。你可以依据自身需求选择合适的软件仓库。

阅读更多 >>>  linux怎么配yum

文章数据信息:

本文主要探讨:"linux中如何配置yum源", 浏览人数已经达到31次, 首屏加载时间:6.387 秒。