ubuntu更换国内源
时间: 2023-10-14 20:26:00 浏览: 73
1. 打开终端,输入以下命令备份系统原始的源文件:
```
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
```
2. 编辑源列表:
```
sudo gedit /etc/apt/sources.list
```
3. 将原有的源地址替换成国内的源地址,以下是常用的源地址:
阿里源:
```
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
```
清华源:
```
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
```
中科大源:
```
deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
```
4. 更新源:
```
sudo apt-get update
```
如果出现错误,可以使用以下命令来更新:
```
sudo apt-get update --fix-missing
```
5. 更新系统:
```
sudo apt-get upgrade
```
或者
```
sudo apt-get dist-upgrade
```
6. 更新完毕后,可以使用以下命令清除无用的软件包和缓存文件:
```
sudo apt-get autoclean
sudo apt-get autoremove
sudo apt-get clean
```
至此,Ubuntu的软件源已经更换为国内源。
阅读全文