apt-get update更新失败问题

2023-05-16

本文借鉴自https://blog.csdn.net/weixin_43976343/article/details/86326215

遇到错误

Err:1 http://mirrors.aliyun.com/ubuntu xenial InRelease
Could not resolve ‘mirrors.aliyun.com’
Err:2 http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease
Could not resolve ‘archive.ubuntukylin.com’
Err:3 http://mirrors.aliyun.com/ubuntu xenial-security InRelease
Could not resolve ‘mirrors.aliyun.com’
Err:4 http://mirrors.aliyun.com/ubuntu xenial-updates InRelease
Could not resolve ‘mirrors.aliyun.com’
Err:5 http://mirrors.aliyun.com/ubuntu xenial-backports InRelease
Could not resolve ‘mirrors.aliyun.com’
Err:6 http://mirrors.aliyun.com/ubuntu xenial-proposed InRelease
Could not resolve ‘mirrors.aliyun.com’
Err:7 http://old-releases.ubuntu.com/ubuntu jaunty InRelease
Could not resolve ‘old-releases.ubuntu.com’
Reading package lists… Done
W: Failed to fetch http://old-releases.ubuntu.com/ubuntu/dists/jaunty/InRelease Could not resolve ‘old-releases.ubuntu.com’
W: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/xenial/InRelease Could not resolve ‘mirrors.aliyun.com’
W: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/xenial-security/InRelease Could not resolve ‘mirrors.aliyun.com’
W: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/xenial-updates/InRelease Could not resolve ‘mirrors.aliyun.com’
W: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/xenial-backports/InRelease Could not resolve ‘mirrors.aliyun.com’
W: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/xenial-proposed/InRelease Could not resolve ‘mirrors.aliyun.com’
W: Failed to fetch http://archive.ubuntukylin.com:10006/ubuntukylin/dists/xenial/InRelease Could not resolve ‘archive.ubuntukylin.com’
W: Some index files failed to download. They have been ignored, or old ones used instead.

显示为无法解析地址:
检查/etc/resolv.conf,发现之前修改的nameserver总是会被修改为127.0.0.53,无论是改成啥,过段时间,总会变回来。
查看/etc/resolv.conf这个文件

This file is managed by man:systemd-resolved(8). Do not edit.


这说明这个文件是被systemd-resolved这个服务托管的

因此打开文件

sudo vi /etc/systemd/resolved.conf

将阿里(223...)和清华(8...)的域名加上,保存退出

[Resolve]
DNS=223.5.5.5 223.6.6.6 8.8.8.8 8.8.4.4
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes

然后重启

sudo systemctl restart systemd-resolved.service 

再将用阿里的镜像地址替换ubuntu的地址,打开list文件

sudo gedit  /etc/apt/sources.list

原来文件里的ubuntu网址全删掉,将下面的复制进去。 

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

然后刷新一下。

就可以update了。

 

,,,就这个操作我居然找了一个晚上加一个上午,贼气

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

apt-get update更新失败问题 的相关文章

随机推荐