我是基于ChatGPT-turbo-3.5实现的AI助手,在此网站上负责整理和概括文章

本文介绍了多个开源镜像站,包括阿里巴巴、华为、腾讯、网易、校园网联合镜像站、清华大学和USTC提供的软件包镜像服务,旨在加速Linux发行版的下载。文章详细说明了RockyLinux、CentOS和Ubuntu的镜像配置方法,包括使用一键换源脚本和手动编辑配置文件,强调了这些工具在提高下载速度、优化系统更新和增强稳定性方面的实用价值。

# 开源镜像站

# 交互式一键换源脚本

  • 特点介绍 | 资源文档站点.欢迎你!*

  • 需使用 ROOT 用户执行脚本

    # 🏡中国大陆(默认)
    bash <(curl -sSL https://linuxmirrors.cn/main.sh)
    # 🎓中国大陆教育网
    bash <(curl -sSL https://linuxmirrors.cn/main.sh) --edu
    # 🌍海外地区
    bash <(curl -sSL https://linuxmirrors.cn/main.sh) --abroad
    
    
    
    # 使用源代码方式
    bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)
    # 恢复使用官方源
    bash <(curl -sSL https://linuxmirrors.cn/main.sh) --use-official-source

# RockyLinux

  • 阿里云镜像

    sed -e 's|^mirrorlist=|#mirrorlist=|g' \
        -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
        -i.bak \    
        /etc/yum.repos.d/rocky-extras.repo \
        /etc/yum.repos.d/rocky.repo
    
    dnf makecache
  • EPEL 软件仓库

    # 首先从 Extras 里安装 epel-release
    dnf remove epel-release -y
    dnf install epel-release -y
    # 用如下命令自动替换
    sed -e 's!^metalink=!#metalink=!g' \
        -e 's!^#baseurl=!baseurl=!g' \
        -e 's!https\?://download\.fedoraproject\.org/pub/epel!http://mirrors.tuna.tsinghua.edu.cn/epel!g' \
        -e 's!https\?://download\.example/pub/epel!http://mirrors.tuna.tsinghua.edu.cn/epel!g' \
        -i /etc/yum.repos.d/epel{,-testing}.repo
        
    #运行测试
    dnf update

# Centos

  • 阿里镜像 https://developer.aliyun.com/mirror/centos

    # CentOS 6
    
    wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
    或者
    curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
    # CentOS 7
    
    wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
    或者
    curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
    # CentOS 8
    
    wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
    或者
    curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
  • 非阿里云ECS 可自行修改相关配置

    # 非阿里云ECS用户会出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影响使用。
    sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
    
  • yum 更新缓存

    yum clean all     		# 清除系统所有的yum缓存
    yum makecache     		# 生成yum缓存
    yum repolist all		# 查看所有的yum源
    yum repolist enabled	# 查看可用的yum源
    
    # yum update不要随便执行,会更新系统内核
    # 升级所有包,改变软件设置和系抄统设置,系统版本内核都升级。
    yum -y update
    # 升级所有包,不改变软件设置和系统设置,系统版本升级,内核不改变。
    yum -y upgrade

# Ubuntu

# 换成清华源 另外请注意,wsl的Ubuntu证书是过期的,如果你想手动还源的话请记得先更新证书
# 直接在Linux里执行,即可换成清华源
# wget https://gitee.com/lin-xi-269/tools/raw/master/os/QHubuntu20.04 && bash QHubuntu20.04

#阿里源
$ sudo vim /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse


## 2204  https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse

# 版本更新
sudo apt-get update
sudo apt-get upgrade

sudo apt install vim wget curl git -y