【Ubuntu】Ubuntu 18.04 LTS 更换国内源——解决终端下载速度慢的问题 - 知乎
一、更换/etc/apt/文件里的源
1. 备份源列表
Ubuntu配置的默认源并不是国内的服务器,下载更新软件都比较慢。首先备份源列表文件:
# 首先备份源列表
sudo cp /etc/apt/ /etc/apt/sources.list_backup
2. 打开文件修改
选择合适的源,替换原文件的内容,保存编辑好的文件, 以阿里云更新服务器为例(可以分别测试阿里云、清华、中科大、163源的速度,选择最快的):
# 打开文件
sudo gedit /etc/apt/
编辑/etc/apt/文件, 在文件最前面添加阿里云镜像源:
# 阿里源
deb /ubuntu/ bionic main restricted universe multiverse
deb /ubuntu/ bionic-security main restricted universe multiverse
deb /ubuntu/ bionic-updates main restricted universe multiverse
deb /ubuntu/ bionic-proposed main restricted universe multiverse
deb /ubuntu/ bionic-backports main restricted universe multiverse
deb-src /ubuntu/ bionic main restricted universe multiverse
deb-src /ubuntu/ bionic-security main restricted universe multiverse
deb-src /ubuntu/ bionic-updates main restricted universe multiverse
deb-src /ubuntu/ bionic-proposed main restricted universe multiverse
deb-src /ubuntu/ bionic-backports main restricted universe multiverse
3. 刷新列表
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
下载速度瞬间就起飞了。
4. 其他源
中科大源:
# 中科大源
deb /ubuntu/ bionic main restricted universe multiverse
deb-src /ubuntu/ bionic main restricted universe multiverse
deb /ubuntu/ bionic-updates main restricted universe multiverse
deb-src /ubuntu/ bionic-updates main restricted universe multiverse
deb /ubuntu/ bionic-backports main restricted universe multiverse
deb-src /ubuntu/ bionic-backports main restricted universe multiverse
deb /ubuntu/ bionic-security main restricted universe multiverse
deb-src /ubuntu/ bionic-security main restricted universe multiverse
deb /ubuntu/ bionic-proposed main restricted universe multiverse
deb-src /ubuntu/ bionic-proposed main restricted universe multiverse
163源:
# 163源
deb http://mirrors./ubuntu/ bionic main restricted universe multiverse
deb http://mirrors./ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors./ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors./ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors./ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors./ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors./ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors./ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors./ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors./ubuntu/ bionic-backports main restricted universe multiverse
清华源:
# 清华源
deb /ubuntu/ bionic main restricted universe multiverse
deb-src /ubuntu/ bionic main restricted universe multiverse
deb /ubuntu/ bionic-updates main restricted universe multiverse
deb-src /ubuntu/ bionic-updates main restricted universe multiverse
deb /ubuntu/ bionic-backports main restricted universe multiverse
deb-src /ubuntu/ bionic-backports main restricted universe multiverse
deb /ubuntu/ bionic-security main restricted universe multiverse
deb-src /ubuntu/ bionic-security main restricted universe multiverse
deb /ubuntu/ bionic-proposed main restricted universe multiverse
deb-src /ubuntu/ bionic-proposed main restricted universe multiverse
更换速度依然还是很慢就请继续往下看第二种方法。
二、更换software&updates里的select best server
这种方法不需要改什么文件,直接在select best server里自动选择。
1. 首先在Show Applications找Software & Updates:
搜索software & updates
打开software & updates
2. 打开software & updates,download from里选择other:
download from选择other
3. 然后点击select best server按钮,它会找到最快的那个,然后点击choose server,就选好镜像了:
我这里搜到的阿里云的源:
4. 把other software选项中除了阿里云的镜像源的对勾都去掉了,目前没有啥影响:
5. 终端里输入sudo apt-get update,速度瞬间快的飞起。
sudo apt-get update