1. 备份原来的更新源
sudo cp -p /etc/apt/sources.list /etc/apt/sources.list.bak
2. 修改更新源
编辑apt源文件,替换为阿里源
sudo vim /etc/apt/sources.list
将文件内容全部清除,将一下内容粘贴进去
deb http://mirrors.aliyun.com/ubuntu-ports eoan main restricted
deb http://mirrors.aliyun.com/ubuntu-ports eoan-updates main restricted
deb http://mirrors.aliyun.com/ubuntu-ports eoan universe
deb http://mirrors.aliyun.com/ubuntu-ports eoan-updates universe
deb http://mirrors.aliyun.com/ubuntu-ports eoan multiverse
deb http://mirrors.aliyun.com/ubuntu-ports eoan-updates multiverse
deb http://mirrors.aliyun.com/ubuntu-ports eoan-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports eoan-security main restricted
deb http://mirrors.aliyun.com/ubuntu-ports eoan-security universe
deb http://mirrors.aliyun.com/ubuntu-ports eoan-security multiverse
或者直接使用替换指令
进入vim编辑界面
sudo vim /etc/apt/sources.list
在命令模式下执行以下指令
:1,$s/ports.ubuntu.com\/ubuntu-ports/mirrors.aliyun.com\/ubuntu-ports\//g
保存退出
:wq
3. 修改 resolv.conf 文件
sudo vim /etc/resolv.conf
在resolv.conf 文件后面添加
nameserver 8.8.8.8
nameserver 8.8.4.4
4. 重启网络
sudo /etc/init.d/networking restart
5. 执行更新
sudo apt-get update
sudo apt-get upgrade
来源:oschina
链接:https://my.oschina.net/zhenggao/blog/4330368