当前位置: 首页 > news >正文

Linux操作系统从入门到实战:怎么查看,删除,更新本地的软件镜像源

Linux操作系统从入门到实战:怎么查看,删除,更新本地的软件镜像源

  • 前言
  • 一、 查看当前镜像源
  • 二、删除当前镜像源
  • 三、更新镜像源
  • 四、验证


前言

  • 我的Linux版本是CentOS 9 stream
  • 本篇博客我们来讲解怎么查看,删除,更新国内本地的软件镜像源

我的个人主页,欢迎来阅读我的其他文章
https://blog.csdn.net/2402_83322742?spm=1011.2415.3001.5343
我的Linux知识文章专栏
欢迎来阅读指出不足
https://blog.csdn.net/2402_83322742/category_12879535.html?spm=1001.2014.3001.5482


  • 在 CentOS 9 Stream 系统中,管理软件镜像源主要通过修改/etc/yum.repos.d/目录下的配置文件来实现
    在这里插入图片描述

一、 查看当前镜像源

  • 列出所有可用的镜像源配置
ls /etc/yum.repos.d/

移动到当前镜像源

cd /etc/yum.repos.d
tree

在这里插入图片描述

  • 常见的源文件有:CentOS-Stream-AppStream.repo、CentOS-Stream-BaseOS.repo 等

  • 查看某个源的具体内容

cat centos.repo

在这里插入图片描述

二、删除当前镜像源

  • 首先我们需要备份一下我们的镜像源文件
sudo cp /etc/yum.repos.d/centos-addons.repo     /etc/yum.repos.d/centos-addons.repo.bak

在这里插入图片描述

sudo cp /etc/yum.repos.d/centos.repo     /etc/yum.repos.d/centos.repo.bak

在这里插入图片描述

  • 然后执行删除镜像源代码
  • 方法一:直接删除配置文件(不推荐,可能影响系统更新)
sudo rm /etc/yum.repos.d/centos-addons.repo
sudo rm /etc/yum.repos.d/centos.repo

在这里插入图片描述

  • 方法二:注释掉配置文件中的 baseurl 和 mirrorlist 行
sudo sed -i 's/^baseurl=/#baseurl=/g' /etc/yum.repos.d/centos.repo

在这里插入图片描述

三、更新镜像源

  • 首先创建镜像源的文件夹
sudo vim /etc/yum.repos.d/centos.repo

在这里插入图片描述

  • 在里面添加下面的代码
[baseos]
name=CentOS Stream $releasever - BaseOS
metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-$stream&arch=$basearch&protocol=https,http
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1[baseos-debuginfo]
name=CentOS Stream $releasever - BaseOS - Debug
metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-debug-$stream&arch=$basearch&protocol=https,http
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0[baseos-source]
name=CentOS Stream $releasever - BaseOS - Source
metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-source-$stream&arch=source&protocol=https,http
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0[appstream]
name=CentOS Stream $releasever - AppStream
metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-$stream&arch=$basearch&protocol=https,http
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1[appstream-debuginfo]
name=CentOS Stream $releasever - AppStream - Debug
metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-debug-$stream&arch=$basearch&protocol=https,http
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0[appstream-source]
name=CentOS Stream $releasever - AppStream - Source
metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-source-$stream&arch=source&protocol=https,http
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0[crb]
name=CentOS Stream $releasever - CRB
metalink=https://mirrors.centos.org/metalink?repo=centos-crb-$stream&arch=$basearch&protocol=https,http
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=0[crb-debuginfo]
name=CentOS Stream $releasever - CRB - Debug
metalink=https://mirrors.centos.org/metalink?repo=centos-crb-debug-$stream&arch=$basearch&protocol=https,http
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0[crb-source]
name=CentOS Stream $releasever - CRB - Source
metalink=https://mirrors.centos.org/metalink?repo=centos-crb-source-$stream&arch=source&protocol=https,http
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0
  • 国内阿里云镜像源
[baseos]
name=CentOS Stream \$releasever - BaseOS
mirrorlist=https://mirrors.aliyun.com/centos-stream/\$releasever/BaseOS/\$basearch/os/mirrorlist
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official[appstream]
name=CentOS Stream \$releasever - AppStream
mirrorlist=https://mirrors.aliyun.com/centos-stream/\$releasever/AppStream/\$basearch/os/mirrorlist
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official
  • 清华大学镜像
[baseos]
name=CentOS Stream \$releasever - BaseOS
mirrorlist=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/\$releasever/BaseOS/\$basearch/os/mirrorlist
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official[appstream]
name=CentOS Stream \$releasever - AppStream
mirrorlist=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/\$releasever/AppStream/\$basearch/os/mirrorlist
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official
  • 华为云镜像
[baseos]
name=CentOS Stream \$releasever - BaseOS
mirrorlist=https://repo.huaweicloud.com/repository/conf/CentOS-Stream-Mirrors.repo?repo=\$releasever/BaseOS/\$basearch/os
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official[appstream]
name=CentOS Stream \$releasever - AppStream
mirrorlist=https://repo.huaweicloud.com/repository/conf/CentOS-Stream-Mirrors.repo?repo=\$releasever/AppStream/\$basearch/os
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official

四、验证

  • 首先清理缓存
sudo dnf clean all

在这里插入图片描述

  • 验证镜像源是否生效
sudo dnf repolist -v

在这里插入图片描述


以上就是这篇博客的全部内容,下一篇我们将继续探索Linux的更多精彩内容。

我的个人主页
欢迎来阅读我的其他文章
https://blog.csdn.net/2402_83322742?spm=1011.2415.3001.5343
我的Linux知识文章专栏
欢迎来阅读指出不足
https://blog.csdn.net/2402_83322742/category_12879535.html?spm=1001.2014.3001.5482

非常感谢您的阅读,喜欢的话记得三连哦

在这里插入图片描述

http://www.lryc.cn/news/584852.html

相关文章:

  • Linux权限的概念
  • 一文速览DeepSeek-R1的本地部署——可联网、可实现本地知识库问答(附教程)
  • 飞算Java AI:专为 Java 开发者打造的智能开发引擎
  • Linux:多线程---同步生产者消费者模型
  • 【Linux仓库】命令行参数与环境变量【进程·伍】
  • 【前端】【Echarts】【zrender】从入门到多路径信号流动动画实战
  • 飞算JavaAI:革新Java开发的智能助手
  • Linux kernel devm_gpiod_get()函数详解
  • 彻底解决JavaFx在Linux中文无法正常显示的问题(究其根本原因)
  • 飞书CEO谢欣:挑战巨头,打造AI新时代的Office
  • 锁的艺术:从Mutex到ReentrantLock,掌握并发编程的脉搏
  • 分布式系统高可用性设计-负载均衡与容错机制深度解析
  • Shader面试题100道之(81-100)
  • 模拟实现unordered_map
  • 如何使用 Python 删除 Excel 中的行、列和单元格 – 详解
  • 如何从0开始构建自己的第一个AI应用?(Prompt工程、Agent自定义、Tuning)
  • 格密码--数学基础--02基变换、幺模矩阵与 Hermite 标准形
  • AI金融风控:识别欺诈,量化风险的新利器
  • pandas销售数据分析
  • python 在 Linux CentOS 上安装 playwright 的完整步骤
  • Pandas:常见的转换函数(rename,set_index,reset_index)
  • MD2Doc转换器(基于Python)
  • [Reverse1] Tales of the Arrow
  • 飞算 JavaAI 深度体验:开启 Java 开发智能化新纪元
  • 闲庭信步使用图像验证平台加速FPGA的开发:第八课——图像数据的行缓存
  • Locust 负载测试工具使用教程
  • 为什么选择Selenium自动化测试?
  • [特殊字符]远程服务器配置pytorch环境
  • ajax和XMLHttpRequest以及fetch
  • STM32-DAC数模转换