Ubuntu如何更换国内源
时间: 2024-01-22 11:13:42 浏览: 74
更换Ubuntu的国内源可以提高软件及插件的下载速度,具体步骤如下:
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
4. 保存文件并关闭。
5. 在终端中输入以下命令更新源:sudo apt-get update
6. 输入以下命令升级软件:sudo apt-get upgrade
7. 重启电脑使更改生效。
相关问题
ubuntu更换国内源
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的软件源已经更换为国内源。
ubuntu 更换国内源
您可以通过以下步骤更换 Ubuntu 的国内源:
1. 打开终端(Terminal),输入以下命令备份原有的源列表文件:
```
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
```
2. 打开源列表文件:
```
sudo vim /etc/apt/sources.list
```
3. 将文件内容替换为以下内容(以清华大学的 Ubuntu 镜像为例):
```
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src 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-src 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-src 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-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
```
4. 保存文件并退出 vim。
5. 运行以下命令更新源列表:
```
sudo apt-get update
```
这样,您就成功更换了 Ubuntu 的国内源。
阅读全文