解决Ubuntu报“无法解析域名cn.archive.ubuntu.com“问题

今天在Ubuntu系统上,使用sudo apt update命令,进行更新时,弹出"无法解析域名 cn.archive.ubuntu.com"问题,如图(1)所示:

图(1) 弹出"无法解析域名 cn.archive.ubuntu.com" 错误

出现这种现象的原因: cn.archive.ubuntu.com这个网站的镜像资源不稳定,dns经常解析出错,需要改成稳定性好、速度快的Ubuntu镜像,,比如,

这里推荐163镜像(http://mirrors.163.com/ubuntu/),解决步骤如下:

1 查看Ubuntu的发行版本

查看Ubuntu的发行版本,命令如下:

bash 复制代码
lsb_release -a

由图(2) 可知,当前系统的发行版本是bionic,则Ubuntu的apt源镜像要选择bionic版本。

注意 :镜像源的版本,要与当前系统的发行版本(代号版本)保持一致。

图(2) 查看Ubuntu的发行版本(即代号,昵称)

2 备份sources.list

bash 复制代码
sudo  cp  /etc/apt/sources.list    /etc/apt/sources.list.bak

3 修改sources.list的权限

bash 复制代码
su root
chmod 666 /etc/apt/sources.list

4 填写Ubuntu镜像

将原来的sources.list文件里的内容清空,然后,填入如下的163的apt源(镜像):

bash 复制代码
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

5 刷新apt源

bash 复制代码
sudo apt-get update
sudo apt-get upgrade

6 其他镜像

6.1 阿里云的Ubuntu镜像

bash 复制代码
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

6.2 清华的Ubuntu镜像

bash 复制代码
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

6.3 中科大的Ubuntu镜像

bash 复制代码
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
相关推荐
偶像你挑的噻9 分钟前
12-Linux驱动开发- SPI子系统
linux·驱动开发·stm32·嵌入式硬件
无限进步_26 分钟前
C语言数组元素删除算法详解:从基础实现到性能优化
c语言·开发语言·windows·git·算法·github·visual studio
松涛和鸣34 分钟前
16、C 语言高级指针与结构体
linux·c语言·开发语言·数据结构·git·算法
念风1 小时前
[lvgl]如何优雅地向lv_port_linux中添加tslib支持
linux
自由的好好干活2 小时前
使用Qoder编写ztdaq的C#跨平台示例总结
linux·windows·c#·qoder
赖small强2 小时前
【Linux 网络基础】libwebsockets HTTPS 服务端实现机制详解
linux·网络·https·tls·libwebsockets
optimistic_chen3 小时前
【Redis 系列】Redis详解
linux·数据库·redis·缓存·xsheel
低客的黑调3 小时前
了解JVM 结构和运行机制,从小白编程Java 大佬
java·linux·开发语言
想唱rap3 小时前
C++ map和set
linux·运维·服务器·开发语言·c++·算法
CodeByV3 小时前
【Linux】Ext 系列文件系统深度解析:从磁盘到软硬链接
linux·服务器