Ubantu设置国内镜像(阿里云、华为云)

1. 确定系统版本

国内有很多 Ubuntu 的镜像源,包括阿里的、网易的,还有很多教育网的源,比如:清华源、中科大源等。

不同的 ubantu 版本对应的镜像源有所不同,所以需要先查看系统的版本号:

bash 复制代码
lsb_release -a

// output
root@DESKTOP-Q58L5PB:/etc/apt# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

可以看到系统的版本号是 20.04.6 LTS,注意这个开发代号 Codename = focal,Ubuntu每一个版本都有一个代号,这个一定要跟国内源对应,否则会出问题。


2. 镜像

2.1 阿里云镜像

通过以下地址可以看到阿里云 Ubuntu 各个版本的镜像地址,从中选择自己的系统版本就好,一定要选择 Codename 对应的版本。镜像地址: ubuntu镜像_ubuntu下载地址_ubuntu安装教程-阿里巴巴开源镜像站

以下是20.04.6 LTS 对应 forcal 的镜像源信息。

bash 复制代码
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

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

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

# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
  1. 备份官方镜像
bash 复制代码
sudo cp /etc/apt/sources.list /etc/apt/sources.list.back
  1. 编辑 sources.list
bash 复制代码
vim /etc/apt/sources.list
  1. 更新镜像源
bash 复制代码
sudo apt update
sudo apt upgrade

2.2 其他

ubuntu | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

ubuntu | 镜像站使用帮助 | 华为软件镜像站


Reference

  1. https://blog.csdn.net/MacWx/article/details/137689898
  2. https://blog.csdn.net/shenzhenyancheng/article/details/126786768
相关推荐
yzx9910133 分钟前
Linux 系统中的算法技巧与性能优化
linux·算法·性能优化
fengyehongWorld4 分钟前
Linux Docker的简介
linux·docker
曹瑞曹瑞36 分钟前
VMware导入vmdk文件
linux·运维·服务器
Johny_Zhao39 分钟前
2025年6月Docker镜像加速失效终极解决方案
linux·网络·网络安全·docker·信息安全·kubernetes·云计算·containerd·yum源·系统运维
hello kitty w1 小时前
Python学习(7) ----- Python起源
linux·python·学习
十年磨一剑~1 小时前
centos查看开启关闭防火墙状态
linux·运维·centos
vortex52 小时前
探索 Shell:选择适合你的命令行利器 bash, zsh, fish, dash, sh...
linux·开发语言·bash·shell·dash
cooldream20093 小时前
华为云Flexus+DeepSeek征文|华为云一键部署知识库搜索增强版Dify平台,构建智能聊天助手实战指南
华为云·dify·deepseek大模型
GalaxyPokemon3 小时前
LeetCode - 148. 排序链表
linux·算法·leetcode
懒羊羊大王呀3 小时前
Ubuntu20.04中 Redis 的安装和配置
linux·redis