当前位置: 首页 > 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.dtcms.com/a/274623.html

相关文章:

  • Python 类型注解实战:`Optional` 与安全数据处理的艺术
  • 递归与树形结构在前端的应用
  • 林吉特危机下的技术革命:马来西亚金融系统升维作战手册
  • 【深度探究系列(5)】:前端开发打怪升级指南:从踩坑到封神的解决方案手册
  • U-Net网络学习笔记(1)
  • ARM单片机OTA解析(二)
  • cesium添加原生MVT矢量瓦片方案
  • 在 Spring Boot 中使用 WebMvcConfigurer
  • 【SpringBoot】配置文件学习
  • linux kernel struct regmap_config结构详解
  • 力扣242.有效的字母异位词
  • MySQL5.7版本出现同步或插入中文出现乱码或???显示问题处理
  • vector之动态二维数组的底层
  • django queryset 去重
  • JavaSE -- StreamAPI 详细介绍(上篇)
  • Java开发新宠!飞算JavaAI深度体验评测
  • 获取华为开源3D引擎 (OpenHarmony),把引擎嵌入VUE中
  • string模拟实现
  • 信号肽预测工具PrediSi本地化
  • 《打破预设的编码逻辑:Ruby元编程的动态方法艺术》
  • 内存踩踏全解析:原理 + 实战案例 + 项目排查技巧
  • 2025十大免费销售管理软件推荐
  • 基于物联网的智能体重秤设计与实现
  • 测试第一定律
  • 如何通过公网IP访问部署在kubernetes中的服务?
  • AVL平衡二叉树
  • 为什么必须掌握Java异常处理机制?——从代码健壮性到面试必考题全解析
  • 阿里云服务器,CentOS7.9上安装YApi 接口管理平台
  • Linux修炼:权限
  • vue2往vue3升级需要注意的点(个人建议非必要别直接升级)