ubuntu更换国内源
时间: 2023-10-14 08:19:11 浏览: 86
您可以按照以下步骤更换Ubuntu的国内源:
1. 打开终端,输入以下命令以备份原有的软件源列表:
```
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
```
2. 编辑软件源列表文件:
```
sudo gedit /etc/apt/sources.list
```
3. 将原有的内容注释掉,添加新的国内源,比如阿里云的源:
```
# deb-src http://archive.ubuntu.com/ubuntu bionic main restricted #注释掉默认的源
# deb-src http://archive.ubuntu.com/ubuntu bionic-updates main restricted #注释掉默认的源
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. 保存文件并退出。
5. 更新软件源列表:
```
sudo apt-get update
```
6. 安装软件:
```
sudo apt-get install 软件名称
```
请注意,不同版本的Ubuntu可能有不同的软件源列表文件,以上示例适用于Ubuntu 18.04版本。在更换国内源时,请选择可靠的源,避免使用不安全的源。
阅读全文