【Linux】Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

一、问题描述

在apt install时候遇到E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? 的error。

Error报的信息显示是这个包向source里的资源下载失败了,但是原因是多种多样的,这里做了个总结,以防下次踩坑:

 

二、问题解决

1.source本身的问题

根据提示,我们首先应当 apt-get update 一下source,如果在apt-get update后依然报这个error,那就说明这个source本省就有错误,尝试apt-get update --fix-missing后依旧报这个error,果断换source。

输入命令:

sudo cp sources.list sources.list.bak

就是先将sources.list备份到sources.list.bak

将 /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

更多源请参考:https://www.cnblogs.com/X-knight/p/10598498.html

最后sudo apt-get update一下就OK了。

2、网络的问题

网关错误拦截了数据包或者防火墙故意将其屏蔽在外(比方update 包含有google-chrome浏览器的source时候,ip 会自动重定向至6.6.6.6) 

sudo vim /etc/resolv.conf
添加:
nameserver 8.8.8.8
nameserver 223.5.5.5
nameserver 223.6.6.6

或是换网络试一下或者参见该配置代理即可。

最后sudo apt-get update一下就OK了。

(我这里是试第一个方法就成功了,只是替换的是公司内的source文件)

转自:https://www.cnblogs.com/X-knight/p/10598076.html

posted @ 2022-09-30 15:03  vickylinj  阅读(1091)  评论(0编辑  收藏  举报