Rocky、Ubuntu软件源定制
一、Rocky Linux 9 配置阿里云镜像源
1. 进入源配置目录
cd /etc/yum.repos.d2. 备份原始源配置文件
cp rocky.repo rocky.repo.bak3. 编辑 rocky.repo 配置文件
写入以下阿里云镜像源配置:
vim rocky.repo[baseos] name=Rocky Linux $releasever - BaseOS baseurl=https://mirrors.aliyun.com/rockylinux/9.6/BaseOS/x86_64/os/ gpgcheck=0 [appstream] name=Rocky Linux $releasever - AppStream baseurl=https://mirrors.aliyun.com/rockylinux/9.6/AppStream/x86_64/os/ gpgcheck=0 enabled=1保存退出(ESC→:wq)
4. 更新 YUM 缓存
yum makecache执行成功输出:
Rocky Linux 9 - BaseOS 19 kB/s | 4.1 kB 00:00 Rocky Linux 9 - AppStream 24 kB/s | 4.5 kB 00:00 Metadata cache created.二、Ubuntu 24.04 配置国内镜像源
1. 查看默认源文件路径
cat /etc/apt/sources.list输出提示:
# Ubuntu sources have moved to /etc/apt/sources.list.d/ubuntu.sources2. 备份原始源文件
# 进入源配置目录 cd /etc/apt/sources.list.d # 创建备份目录 mkdir /data/bak/source-bak -p # 移动所有原始源文件到备份目录 mv * /data/bak/source-bak/3. 编辑 APT 源配置文件
vim /etc/apt/sources.list写入阿里云 + 清华大学双镜像源配置:
# 阿里云镜像仓库 deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse # 清华大学镜像仓库 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse保存退出(ESC→:wq)
4. 更新 APT 软件源
apt update执行成功输出(关键信息):
命中:1 https://mirrors.aliyun.com/ubuntu noble InRelease 获取:2 https://mirrors.aliyun.com/ubuntu noble-security InRelease [126 kB] 获取:3 https://mirrors.aliyun.com/ubuntu noble-updates InRelease [126 kB] 命中:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble InRelease ... 已下载 1,032 kB,耗时 1秒 (751 kB/s) 正在读取软件包列表... 完成 正在分析软件包的依赖关系树... 完成 正在读取状态信息... 完成 有 171 个软件包可以升级。