ANALYSIS
常用国内镜像源
阿里云镜像源
PRTCL // PLAINTEXT
deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse清华大学镜像源
PRTCL // PLAINTEXT
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-security main restricted universe multiverse中科大镜像源
PRTCL // PLAINTEXT
deb https://mirrors.ustc.edu.cn/ubuntu/ noble main restricted universe multiversedeb https://mirrors.ustc.edu.cn/ubuntu/ noble-updates main restricted universe multiversedeb https://mirrors.ustc.edu.cn/ubuntu/ noble-backports main restricted universe multiversedeb https://mirrors.ustc.edu.cn/ubuntu/ noble-security main restricted universe multiverse网易镜像源
PRTCL // PLAINTEXT
deb https://mirrors.163.com/ubuntu/ noble main restricted universe multiversedeb https://mirrors.163.com/ubuntu/ noble-updates main restricted universe multiversedeb https://mirrors.163.com/ubuntu/ noble-backports main restricted universe multiversedeb https://mirrors.163.com/ubuntu/ noble-security main restricted universe multiverse换源步骤
第一步:备份原有源文件
PRTCL // BASH
sudo cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak第二步:查看当前源配置
Ubuntu 24.04 使用新的 DEB822 格式:
PRTCL // BASH
cat /etc/apt/sources.list.d/ubuntu.sources第三步:编辑源文件
PRTCL // BASH
sudo nano /etc/apt/sources.list.d/ubuntu.sources第四步:替换源内容
方法 1:使用 DEB822 格式 ( 推荐 )
将文件内容替换为以下内容 ( 以阿里云为例 ):
PRTCL // PLAINTEXT
Types: debURIs: https://mirrors.aliyun.com/ubuntu/Suites: noble noble-updates noble-backportsComponents: main restricted universe multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: debURIs: https://mirrors.aliyun.com/ubuntu/Suites: noble-securityComponents: main restricted universe multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg清华源 DEB822 格式:
PRTCL // PLAINTEXT
Types: debURIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/Suites: noble noble-updates noble-backportsComponents: main restricted universe multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: debURIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/Suites: noble-securityComponents: main restricted universe multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg中科大源 DEB822 格式:
PRTCL // PLAINTEXT
Types: debURIs: https://mirrors.ustc.edu.cn/ubuntu/Suites: noble noble-updates noble-backportsComponents: main restricted universe multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: debURIs: https://mirrors.ustc.edu.cn/ubuntu/Suites: noble-securityComponents: main restricted universe multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg方法 2:使用传统格式
如果需要使用传统格式,可以编辑/etc/apt/sources.list:
PRTCL // BASH
sudo nano /etc/apt/sources.list添加以下内容 ( 以阿里云为例 ):
PRTCL // PLAINTEXT
deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiversedeb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiversedeb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiversedeb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse参数说明:
deb: 二进制软件包deb-src: 源代码包 ( 可选 )noble: Ubuntu 24.04 的代号main: 官方支持的自由软件restricted: 官方支持的非完全自由软件universe: 社区维护的自由软件multiverse: 非自由软件
第五步:保存文件
- nano 编辑器: 按
Ctrl + O保存,Ctrl + X退出 - vim 编辑器: 按
ESC,输入:wq保存退出
第六步:更新软件包列表
PRTCL // BASH
sudo apt update第七步:升级已安装的软件包 ( 可选 )
PRTCL // BASH
sudo apt upgrade -y一键换源脚本
阿里云源
PRTCL // BASH
sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list.d/ubuntu.sourcessudo apt update清华源
PRTCL // BASH
sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sourcessudo apt update中科大源
PRTCL // BASH
sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sourcessudo apt update验证换源成功
查看当前源配置
PRTCL // BASH
cat /etc/apt/sources.list.d/ubuntu.sources测试下载速度
PRTCL // BASH
sudo apt update观察下载速度,应该明显提升。
安装测试软件
PRTCL // BASH
sudo apt install neofetch -y如果安装速度很快,说明换源成功。
恢复默认源
如果换源后出现问题,可以恢复备份:
PRTCL // BASH
sudo cp /etc/apt/sources.list.d/ubuntu.sources.bak /etc/apt/sources.list.d/ubuntu.sourcessudo apt update或手动恢复为官方源:
PRTCL // BASH
sudo nano /etc/apt/sources.list.d/ubuntu.sources替换为官方源:
PRTCL // PLAINTEXT
Types: debURIs: http://archive.ubuntu.com/ubuntu/Suites: noble noble-updates noble-backportsComponents: main restricted universe multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: debURIs: http://security.ubuntu.com/ubuntu/Suites: noble-securityComponents: main restricted universe multiverseSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg常见问题
更新时出现 GPG 错误
PRTCL // BASH
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <KEY_ID>或重新获取密钥:
PRTCL // BASH
sudo apt update --allow-insecure-repositories无法连接到镜像源
检查网络连接:
PRTCL // BASH
ping mirrors.aliyun.com尝试更换其他镜像源。
更新速度仍然很慢
- 尝试更换其他镜像源
- 检查本地网络状况
- 使用
apt-fast加速下载
安装 apt-fast:
PRTCL // BASH
sudo add-apt-repository ppa:apt-fast/stablesudo apt updatesudo apt install apt-fast -ysources.list.d 目录下没有 ubuntu.sources 文件
Ubuntu 24.04 之前的版本使用/etc/apt/sources.list,直接编辑该文件:
PRTCL // BASH
sudo nano /etc/apt/sources.list提示”仓库不支持架构”
确认系统架构:
PRTCL // BASH
dpkg --print-architecture如果是 ARM 架构,需要使用对应的 ARM 镜像源。
其他软件源配置
PPA 源换源
编辑 PPA 源文件:
PRTCL // BASH
sudo nano /etc/apt/sources.list.d/<ppa-name>.listDocker 源换源
PRTCL // BASH
sudo mkdir -p /etc/dockersudo tee /etc/docker/daemon.json <<-'EOF'{ "registry-mirrors": [ "https://docker.mirrors.ustc.edu.cn", "https://hub-mirror.c.163.com", "https://mirror.ccs.tencentyun.com" ]}EOFsudo systemctl daemon-reloadsudo systemctl restart dockerPython pip 换源
临时使用:
PRTCL // BASH
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple <package>永久配置:
PRTCL // BASH
mkdir -p ~/.pipcat > ~/.pip/pip.conf <<EOF[global]index-url = https://pypi.tuna.tsinghua.edu.cn/simple[install]trusted-host = pypi.tuna.tsinghua.edu.cnEOFNode.js npm 换源
PRTCL // BASH
npm config set registry https://registry.npmmirror.com验证:
PRTCL // BASH
npm config get registry推荐镜像源选择
教育网用户
推荐使用教育网镜像:
- 清华大学镜像源
- 中科大镜像源
- 上海交大镜像源
电信用户
推荐使用:
- 阿里云镜像源
- 网易镜像源
联通 / 移动用户
推荐使用:
- 阿里云镜像源
- 腾讯云镜像源
海外用户
使用官方源或就近的区域镜像。
镜像源速度测试
使用 netselect-apt 自动选择最快源
安装工具:
PRTCL // BASH
sudo apt install netselect-apt -y测试并生成 sources.list:
PRTCL // BASH
sudo netselect-apt noble手动测试下载速度
PRTCL // BASH
wget -O /dev/null http://mirrors.aliyun.com/ubuntu/ls-lR.gzwget -O /dev/null http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ls-lR.gzwget -O /dev/null http://mirrors.ustc.edu.cn/ubuntu/ls-lR.gz比较下载速度,选择最快的源。
参考资料
R P
Rhine Lab Pioneer Division
Auth_Verified: 2026.04.08
Auth_Verified: 2026.04.08
