Reasons and solutions for sudo apt-get update failure

A connection timeout occurs when Ubuntu updates resource packages:
Unable to initiate a connection to cn.archive.ubuntu.com:80 (2403:2c80:5::6) - connect (101: The network is unreachable) Unable to connect to cn.archive .ubuntu.com:80 (45.125.0.6), connection timeout
Reading package list... Done
W: Unable to download http://cn.archive.ubuntu.com/ubuntu/dists/focal/InRelease Unable to initiate connection with cn. Archive.ubuntu.com:80 (2403:2c80:5::6) connection - connect (101: Network unreachable) Unable to connect to cn.archive.ubuntu.com:80 (45.125.0.6), connection timed out
W: Some index files failed to download. If you omit them, the old index files will be used instead.

The error message is as shown below:
Insert image description here
The reason is that the Ubuntu server is abroad, and updates when downloading using domestic software sources are restricted, so the service address must be changed to a domestic address. Just replace
everything in the /etc/apt/sources.list file with . You can choose to back up this file first to prevent it from being restored later:cn.archive.ubuntu.commirrors.aliyun.com

cd /etc/apt
sudo tar -zcvf sources.list.tar.gz sources.list

As shown in the figure, a compressed package of a file is backed up.
Insert image description here
Then vim goes into the file and changes it:

sudo vim sources.list

Press i to insert to start modification. After modification, press esc key –> colon: --> wq to save and exit.

Guess you like

Origin blog.csdn.net/weixin_45354497/article/details/133150065