侧边栏壁纸
博主头像
Jammmの日常博主等级

行动起来,活在当下

  • 累计撰写 80 篇文章
  • 累计创建 53 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Linux换源-Centos,Ubuntu,Rocky

Administrator
2025-05-03 / 0 评论 / 0 点赞 / 74 阅读 / 5467 字

最后执行 - 换源完成后执行更新

Centos

sudo yum clean all
sudo yum makecache

Ubuntu

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get upgrade

Rocky

# 清理旧缓存
sudo dnf clean all
 
# 生成新缓存
sudo dnf makecache
 
# 验证配置是否生效(检查仓库地址)
sudo dnf repolist

换源

Centos7

目录:/etc/yum.repos.d/CentOS-Base.repo

#备份yum原文件
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

#阿里云源
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

#清华大学源
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/repo/Centos-7.repo

Centos8


#阿里云源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

#清华大学源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/repo/centos8/CentOS-Base.repo

Ubuntu22源

目录:/etc/apt/sources.list

注意:此为Ubuntu22源

#腾讯源
deb http://mirrors.cloud.tencent.com/ubuntu jammy main restricted
deb http://mirrors.cloud.tencent.com/ubuntu jammy-updates main restricted

deb http://mirrors.cloud.tencent.com/ubuntu jammy universe
deb http://mirrors.cloud.tencent.com/ubuntu jammy-updates universe

deb http://mirrors.cloud.tencent.com/ubuntu jammy multiverse
deb http://mirrors.cloud.tencent.com/ubuntu jammy-updates multiverse

deb http://mirrors.cloud.tencent.com/ubuntu jammy-backports main restricted universe multiverse
deb http://mirrors.cloud.tencent.com/ubuntu jammy-security main restricted

deb http://mirrors.cloud.tencent.com/ubuntu jammy-security universe
deb http://mirrors.cloud.tencent.com/ubuntu jammy-security multiverse

#阿里源
deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

Ubuntu24源

文件位置: /etc/apt/sources.list.d/ubuntu.source

#清华源
Types: deb
URIs: http://mirrors.tuna.tsinghua.edu.cn/ubuntu/
Suites: noble noble-updates noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

#中科大
Types: deb
URIs: http://mirrors.ustc.edu.cn/ubuntu/
Suites: noble noble-updates noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

#阿里
Types: deb
URIs: http://mirrors.aliyun.com/ubuntu/
Suites: noble noble-updates noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg


Rocky换源

目前测试了9.2/9.4

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*.repo && dnf makecache
0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区