ubuntu 22.04 设置国内镜像源(阿里源、清华源)
时间: 2024-09-10 16:13:50 浏览: 283
Ubuntu 22.04 设置国内镜像源主要是为了加快软件包的下载速度,特别是对于非英语地区的用户。以下是设置阿里云和清华大学源的步骤:
1. **安装`software-properties-common`**:
```bash
sudo apt-get update && sudo apt-get install software-properties-common
```
2. **添加阿里云社区源** (替换`mirrors.aliyun.com`为其他版本如`mirrors.aliyuncs.com`):
```bash
sudo add-apt-repository ppa:chenyunkun/aliyun-ubuntu-repo
```
然后运行:
```bash
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E56151AF
sudo apt update
```
3. **选择阿里云仓库作为首选源**:
```bash
sudo sed -i 's/#deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse/deb http://mirrors.aliyun.com/ubuntu focal main restricted universe multiverse/g' /etc/apt/sources.list
sudo sed -i 's/#deb-src http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse/deb-src http://mirrors.aliyun.com/ubuntu focal main restricted universe multiverse/g' /etc/apt/sources.list
```
4. **添加清华大学源** (替换`mirror.tuna.tsinghua.edu.cn`为其他版本):
```bash
sudo add-apt-repository "deb [arch=amd64] http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse"
sudo add-apt-repository "deb-src [arch=amd64] http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse"
```
更新源列表:
```bash
sudo apt update
```
完成以上步骤后,Ubuntu 22.04 就会优先从国内镜像源下载软件包了。
阅读全文