当前位置:网站首页>Error "failed to fetch" XXX "temporary failure resolvingw: some index files failed to download" solution

Error "failed to fetch" XXX "temporary failure resolvingw: some index files failed to download" solution

2022-07-23 18:53:00 wild _ wolf

Solution 1: Restore to original Ubuntu Mirror image

If this error is encountered , The first trick is to switch back to the original image . This involves from /usr/share/doc/apt/examples/sources.list Create a new source list file from the sample source list file in the path .
View the sample source list file , As shown below :

$ cat /usr/share/doc/apt/examples/sources.list

Output is as follows :
 Insert picture description here
But first of all , According to consistent suggestions , Make a backup copy of the source list , As shown below :

$ sudo mv /etc/apt/sources.list{
    ,.backup}
$ sudo mv /etc/apt/sources.list.d{
    ,.backup}

Next , Follow these steps to create a new source list file from the sample source list file :

$ sudo mkdir /etc/apt/sources.list.d
$ sudo cp /usr/share/doc/apt/examples/sources.list /etc/apt/sources.list

Last , Update the repository as shown .

$ sudo apt update

This will restore all mirrors and enable Canonical Supported by “ Lord ” The repository .

To install the community support package 、 Proprietary software packages and software packages that are not available under a completely free license , Consider enabling the following repositories :

Universe – Free and open source software maintained by the community .
Restricted – Device specific drivers .
Multiverse – Software restricted by copyright or legal issues .

To enable these repositories , Please call the following command .

$ sudo add-apt-repository restricted
$ sudo add-apt-repository multiverse
$ sudo add-apt-repository universe

Then update the source table

$ sudo apt update

Solution 2: from Ubuntu Select the latest image in the official image

Consider switching to the image closest to your geographical location ( Usually happens to be the fastest mirror ). The simple way is to ensure that the image defined in the source list file contains relative to the country of residence / Countries in the region / Region code . for example /etc/apt/sources.list The official image of the United States provided in is :

deb http://us.archive.ubuntu.com/ubuntu focal main restricted

Replace it with the domestic Tsinghua source :

#  The source image is annotated by default to improve  apt update  Speed , If necessary, please cancel the comment 
deb http://mirrors.aliyun.com/ubuntu/ yammy main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ yammy-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ yammy-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ yammy-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ yammy-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ yammy main multiverse restricted universe
#deb-src http://mirrors.aliyun.com/ubuntu/ yammy-backports main multiverse restricted universe
#deb-src http://mirrors.aliyun.com/ubuntu/ yammy-proposed main multiverse restricted universe
#deb-src http://mirrors.aliyun.com/ubuntu/ yammy-security main multiverse restricted universe
#deb-src http://mirrors.aliyun.com/ubuntu/ yammy-updates main multiverse restricted universe

Then update the source table

$ sudo apt update

Solution 3: Copy the contents of the source list from a well functioning system

Last , Another way to solve this error is from another functional Ubuntu The system copies the contents of the source list file and pastes them into the source list file of the system . This is by far the easiest way to fix this error .

After all the above attempts, you can modify the configuration file /etc/resolv.conf,

sudo vim /etc/resolv.conf

Add domain name server 8.8.8.8,

nameserver 8.8.8.8

The above methods should help you solve Ubuntu This annoying mistake on . If it helps you , please Click like or collect Oh .

原网站

版权声明
本文为[wild _ wolf]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207231608577381.html