ubuntu更换镜像源
时间: 2023-11-05 13:53:03 浏览: 104
DebianUbuntu关键镜像源替换
Ubuntu 的软件源设置文件位于 `/etc/apt/sources.list`,我们可以通过修改该文件来更换镜像源。
以下是更换为阿里云镜像源的步骤:
1. 备份原有的软件源设置文件
```bash
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
```
2. 使用文本编辑器打开 `/etc/apt/sources.list` 文件
```bash
sudo nano /etc/apt/sources.list
```
3. 将原有的内容注释掉,添加阿里云镜像源的内容
```bash
# 以下为原有的内容,注释掉
# deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
# deb http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
# deb http://archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse
# deb http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
# 以下为阿里云镜像源的内容
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
```
4. 保存并退出编辑器
按下 `Ctrl + X`,然后按下 `Y` 确认保存。
5. 更新软件源
```bash
sudo apt update
```
现在,你已经成功更换 Ubuntu 的镜像源了。
阅读全文