问题描述如下:

拿起了封尘已久的ThinkPad,输入 sudo apt update 的时候,发现这个命令变得不好使了,具体出现的问题如下图所示:

#( 09/08/19@ 2:44下午 )( python@Sakura ):~/下载/shadowsocksr@manyuser✔
sudo apt update
忽略:1 http://dl.google.com/linux/chrome/deb stable InRelease
命中:2 http://dl.google.com/linux/chrome/deb stable Release
0% [正在连接 cn.archive.ubuntu.com] [正在连接 cz.archive.ubuntu.co0% [正在连接 c0% [错误:4 http://ppa.launchpad.net/obsproject/obs-studio/ubuntu bionic InRelease
无法解析域名“ppa.launchpad.net”
错误:5 http://cz.archive.ubuntu.com/ubuntu bionic InRelease
无法解析域名“cz.archive.ubuntu.com”
错误:6 https://packages.microsoft.com/ubuntu/18.04/prod bionic InRelease
无法解析域名“packages.microsoft.com”
错误:7 https://download.sublimetext.com apt/stable/ InRelease
无法解析域名“download.sublimetext.com”
错误:8 https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu bionic InRelease
无法解析域名“mirrors.ustc.edu.cn”
错误:9 http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease
无法解析域名“archive.ubuntukylin.com”
错误:10 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease
无法解析域名“ppa.launchpad.net”
错误:11 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
无法解析域名“cn.archive.ubuntu.com”
错误:12 http://packages.microsoft.com/repos/vscode stable InRelease
无法解析域名“packages.microsoft.com”
错误:13 http://ppa.launchpad.net/openjdk-r/ppa/ubuntu bionic InRelease
无法解析域名“ppa.launchpad.net”
错误:14 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease
无法解析域名“cn.archive.ubuntu.com”
错误:15 http://ppa.launchpad.net/openshot.developers/ppa/ubuntu bionic InRelease
无法解析域名“ppa.launchpad.net”
错误:16 http://cn.archive.ubuntu.com/ubuntu bionic-security InRelease
无法解析域名“cn.archive.ubuntu.com”
错误:17 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu bionic InRelease
无法解析域名“ppa.launchpad.net”
错误:18 http://cn.archive.ubuntu.com/ubuntu bionic-proposed InRelease
无法解析域名“cn.archive.ubuntu.com”
错误:19 http://ppa.launchpad.net/webupd8team/java/ubuntu bionic InRelease
无法解析域名“ppa.launchpad.net”
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
有 382 个软件包可以升级。请执行 ‘apt list --upgradable’ 来查看它们。
W: 无法下载 http://cn.archive.ubuntu.com/ubuntu/dists/bionic/InRelease 无法解析域名“cn.archive.ubuntu.com”
W: 无法下载 http://cn.archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease 无法解析域名“cn.archive.ubuntu.com”
W: 无法下载 http://cn.archive.ubuntu.com/ubuntu/dists/bionic-security/InRelease 无法解析域名“cn.archive.ubuntu.com”
W: 无法下载 http://cn.archive.ubuntu.com/ubuntu/dists/bionic-proposed/InRelease 无法解析域名“cn.archive.ubuntu.com”
W: 无法下载 http://cz.archive.ubuntu.com/ubuntu/dists/bionic/InRelease 无法解析域名“cz.archive.ubuntu.com”
W: 无法下载 https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/dists/bionic/InRelease 无法解析域名“mirrors.ustc.edu.cn”
W: 无法下载 https://packages.microsoft.com/ubuntu/18.04/prod/dists/bionic/InRelease 无法解析域名“packages.microsoft.com”
W: 无法下载 http://ppa.launchpad.net/obsproject/obs-studio/ubuntu/dists/bionic/InRelease 无法解析域名“ppa.launchpad.net”
W: 无法下载 http://ppa.launchpad.net/ondrej/php/ubuntu/dists/bionic/InRelease 无法解析域名“ppa.launchpad.net”
W: 无法下载 http://ppa.launchpad.net/openjdk-r/ppa/ubuntu/dists/bionic/InRelease 无法解析域名“ppa.launchpad.net”
W: 无法下载 http://ppa.launchpad.net/openshot.developers/ppa/ubuntu/dists/bionic/InRelease 无法解析域名“ppa.launchpad.net”
W: 无法下载 http://archive.ubuntukylin.com:10006/ubuntukylin/dists/xenial/InRelease 无法解析域名“archive.ubuntukylin.com”
W: 无法下载 https://download.sublimetext.com/apt/stable/InRelease 无法解析域名“download.sublimetext.com”
W: 无法下载 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu/dists/bionic/InRelease 无法解析域名“ppa.launchpad.net”
W: 无法下载 http://packages.microsoft.com/repos/vscode/dists/stable/InRelease 无法解析域名“packages.microsoft.com”
W: 无法下载 http://ppa.launchpad.net/webupd8team/java/ubuntu/dists/bionic/InRelease 无法解析域名“ppa.launchpad.net”
W: 部分索引文件下载失败。如果忽略它们,那将转而使用旧的索引文件。

我们可以看到,大概我们无法对像"cn.archive.ubuntu.com"、"packages.microsoft.com"之类的网站进行域名解析。出现这一问题主要是因为DNS解析有误,或者是DNS未配置。我们可以查看一下DNS Server:

cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf. nameserver 127.0.0.53
options edns0
search DHCP HOST

只有一个DNS Server的地址 127.0.0.53,我们可以采取如下方法给其配置DNS Server。

解决方案:

方案一:重启会失效

我们只需要加入DNS服务器地址,让其能够自动去解析即可。不过有个问题就是重启以后可能会失效,需要重新对其进行配置。

1. sudo vim /etc/resolv.conf # 添加如下内容
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 127.0.0.1
2. 输入Esc,:wq,保存并退出
3. sudo /etc/init.d/networking restart

我们再输入 sudo apt update 进行更新即可。

方案二:永久有效

1. sudo apt install resolvconf
2. sudo vim /etc/resolvconf/resolv.conf.d/base
在里面插入:
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 127.0.0.1
3. 输入Esc,:wq,保存并退出
4. sudo resolvconf -u
5. cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4

在这里,我还要提一点相关内容。虽然我按照方案二并没有达到想要的这种结果(理论上应该是没问题的),可能是因为我这边配置全局代理,让它默认自动走本地代理路线,所以DNS Server解析的地址为127.0.0.1,不过至少已经可以使用了,如果方案二行不通的同学,你可以采用方案一,稍微麻烦一点,每次都要进行修改罢了。

最终的结果如下:

#( 09/08/19@ 2:58下午 )( python@Sakura ):~/下载/shadowsocksr@manyuser✔
sudo apt update
忽略:1 http://dl.google.com/linux/chrome/deb stable InRelease
命中:2 http://dl.google.com/linux/chrome/deb stable Release
获取:3 http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease [18.1 kB]
获取:4 http://packages.microsoft.com/repos/vscode stable InRelease [3,181 B]
命中:6 http://ppa.launchpad.net/obsproject/obs-studio/ubuntu bionic InRelease
命中:7 https://packages.microsoft.com/ubuntu/18.04/prod bionic InRelease
获取:8 http://packages.microsoft.com/repos/vscode stable/main amd64 Packages [139 kB]
命中:9 http://cz.archive.ubuntu.com/ubuntu bionic InRelease
命中:10 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
命中:11 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease
命中:12 https://download.sublimetext.com apt/stable/ InRelease
获取:13 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
命中:14 http://ppa.launchpad.net/openjdk-r/ppa/ubuntu bionic InRelease
命中:15 http://ppa.launchpad.net/openshot.developers/ppa/ubuntu bionic InRelease
命中:16 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu bionic InRelease
命中:17 http://ppa.launchpad.net/webupd8team/java/ubuntu bionic InRelease
获取:18 http://cn.archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
获取:19 http://cn.archive.ubuntu.com/ubuntu bionic-proposed InRelease [242 kB]
命中:20 https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu bionic InRelease
获取:21 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [285 kB]
获取:22 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [70.9 kB]
获取:23 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [140 kB]
获取:24 http://cn.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,464 B]
获取:25 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [253 kB]
获取:26 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [197 kB]
获取:27 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [447 kB]
获取:28 http://cn.archive.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [22.7 kB]
获取:29 http://cn.archive.ubuntu.com/ubuntu bionic-security/main DEP-11 48x48 Icons [10.4 kB]
获取:30 http://cn.archive.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons [31.7 kB]
获取:31 http://cn.archive.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]
获取:32 http://cn.archive.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [42.1 kB]
获取:33 http://cn.archive.ubuntu.com/ubuntu bionic-security/universe DEP-11 48x48 Icons [16.4 kB]
获取:34 http://cn.archive.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [111 kB]
获取:35 http://cn.archive.ubuntu.com/ubuntu bionic-proposed/main amd64 DEP-11 Metadata [7,160 B]
已下载 2,220 kB,耗时 35秒 (63.8 kB/s)
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
有 383 个软件包可以升级。请执行 ‘apt list --upgradable’ 来查看它们。

这样就OK了。

【亲测有效】Ubuntu18.04 sudo apt update无法解析域名的解决方案的更多相关文章

  1. Ubuntu17.04 sudo apt-get update升级错误

    最近在折腾Ubuntu,安装的是17.04版本的.想安装PHP7.X最新版本,但是要先升级.利用sudo apt-get update命名后,出现了以下报错: 忽略:1 http://cn.archi ...

  2. Ubuntu18下sudo apt install xxx出现问题

    当执行sudo apt install rpm时失败(apt-get也失败),输出如下报错信息: E: Could not get lock /var/lib/dpkg/lock - open (11 ...

  3. sudo apt update报错

    在Ubuntu系统下,使用sudo apt-get update有时会出现“W: 无法下载 http://cn.archive.ubuntu.com/ubuntu/.... 校验和不符”, xj@xj ...

  4. 【亲测有效】Kali Linux无法安装网易云音乐的解决方案

    问题描述 由于 Kali Linux 的内核是基于 Debian 的,我们在安装网易云音乐的时候更偏向于选择安装网易云音乐 v1.1.0 deepin15(64位) 的包,可是我发现在安装过程中,无法 ...

  5. <亲测>ubuntu 16.04 忘记root密码

    ubuntu 16.04 忘记root密码   阅读目录 方法一 方法二 虚拟机中安装的ubuntu 16.04. 回到目录 方法一 如果用户具有sudo权限,那么直接可以运行如下命令: sudo s ...

  6. 关于“ubuntu18.04下网易云无法启动”的问题解决方案

    1. 最简单的解决方案(参考文章:亢奋猫): 更正:在更改启动文件netease-cloud-music.desktop时应为:将第11行处的“Exec=netease-cloud-music %U” ...

  7. win10下安装ubuntu18.04

    在win10下安装Ubuntu18.04,双系统共存.Ubuntu 18.04 使用的是Gnome桌面. 查看系统的启动模式: Win+R打开运行,输入msinfo32,回车查看系统信息.在BIOS模 ...

  8. Ubuntu18.04 NVIDIA显卡驱动 安装大全

    离线安装NVIDIA显卡驱动 费了一天的劲,走了好多的坑,最主要的原因是gcc版本的问题,一定要用最新版本的gcc!!! 1)官网下载显卡驱动 2)apt 下载gcc包及其依赖包,可用apt-cach ...

  9. Ubuntu18.04下MySQL8.0和Navicat15的安装与使用

    目录 一.MySQL8.0安装 二.Navicat安装并与MySQL连接 一.MySQL8.0安装 注意:若直接 sudo apt install mysql-server,你会发现安装后的版本是5. ...

随机推荐

  1. go-爬图片

    go语言爬取图片 注:动态加载出来的爬取不到,或怕取出来图片出错,代码中的网页是可以正常爬取的 package main import ( "fmt" "io" ...

  2. css3动画如何解决动画的播放、暂停和重新开始

    0921自我总结 css3如何解决动画的播放.暂停和重新开始 一.解决的本质思路 播放的解决思路 先定义好动画效果通过类名的增加达到样式的出现 暂停的解决思路 我们播放动画时,如要暂停动画,就要用到a ...

  3. ZooKeeper 面试题

    高强度训练第二十一天总结 1. ZooKeeper 面试题 ZooKeeper 是一个开放源码的分布式协调服务,它是集群的管理者,监视着集群 中各个节点的状态根据节点提交的反馈进行下一步合理操作.最终 ...

  4. PostgreSQL 常用函数

    类似Oracle ,PostgreSQL也有强大的类型转换函数, 下面仅举两个类型转换例子. --1 例子 postgres; ?column? ---------- ( row) 在PG里如果想做除 ...

  5. Bootstrap 时间日历插件bootstrap-datetimepicker配置与应用小结

    Bootstrap时间日历插件bootstrap-datetimepicker配置与应用小结   by:授客 QQ:1033553122 1.   测试环境 win7 JQuery-3.2.1.min ...

  6. RDIFramework.NET敏捷开发框架Web新增邮件中心实现便捷式的邮件收发

    1.引言 邮件收发在很多业务系统中都有这样的需求,是比较正式和常用的功能.在我们的框架中提供了邮件中心功能模块,集内部邮件的收发.邮件归类.邮件星标的标记.邮件的删除与彻底删除等,邮件中心功能模块界面 ...

  7. 安装SQL数据库时遇到问题。需要更新以前的visual studio 2010实例

    安装SQL数据库时遇到问题.需要更新以前的visual studio 2010实例此计算机安装了需要service pack 1更新的visual 2010,必须安装此更新才能成功安装选择的SQL s ...

  8. C#后台架构师成长之路-高阶知识体系核心

    了解了这些东西,熟悉了运用基本都是高工级别的了,其他修修补补就行了.... 1.三种预定义特性:attributeUsage.Conditional.obsolete,允许创建自定义特性,派生自Sys ...

  9. java8-12-Optional类

      Optional类  java.util.Optional   是一个容器类 避免空指针  NPE  能够快速定位空指针   常用方法: Optional.of(T t) : 创建一个 Optio ...

  10. BZOJ2339/LG3214 「HNOI2011」 卡农 组合数学

    问题描述 BZOJ2339 本题的一些心得 对于这种无序集合计数类问题,可以通过对方案数除以某个数的阶乘,使得无序化变为有序化. 设计DP方程时候,应该先有序的列出状态转移方程每一项的来源,并一项项推 ...