ubuntu 换源Could not resolve ‘mirrors.aliyun.com’

骚年
骚年
管理员
23
文章
0
粉丝
常用脚本评论13阅读模式

1. 备份原来的更新源

cp /etc/apt/sources.list /etc/apt/sources.list.backup

如果提示权限不够就输入下面两行,先进入到超级用户,再备份

sudo -s
cp /etc/apt/sources.list /etc/apt/sources.list.backup

 

2. 修改更新源

打开sources.list:

vim /etc/apt/sources.list

阿里云:

# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

 

错误:

Could not resolve 'mirrors.aliyun.com'

1.vim /etc/resolv.conf在文件后面添加:

nameserver 8.8.8.8
nameserver 8.8.4.4

2.重启网络:

sudo /etc/init.d/networking restart

3.再次执行

sudo apt-get update

执行完成,然后:

sudo apt-get upgrade

 

这小玩意还挺有意思?!是吧!

 
骚年
  • 本文由 骚年 发表于2025年11月26日 14:59:56
  • 转载请务必保留本文链接:https://cexunke.com/changyongjiaoben/140.html
匿名

发表评论

匿名网友
确定

拖动滑块以完成验证