Successfully solved sudo apt-get update of ubuntu-22.04 has been stuck at [0% [Waiting for headers]]

Successfully solved sudo apt-get update of ubuntu-22.04 has been stuck at [0% [Waiting for headers]]

Problem Description

When downloading the installation package, it has been stuck at 0% [Waiting for headers], 报错信息as follows:

Get:1 file:/var/cudnn-local-repo-ubuntu1804-8.5.0.96 InRelease [1,575 B]
Get:1 file:/var/cudnn-local-repo-ubuntu1804-8.5.0.96 InRelease [1,575 B]
Get:2 file:/var/cudnn-local-repo-ubuntu1804-8.5.0.96 Packages [950 B]
Get:3 https://dl.google.com/linux/chrome/deb stable InRelease [1,825 B]
Get:4 https://dl.google.com/linux/chrome/deb stable/main amd64 Packages [1,088 B]
Get:5 https://packages.microsoft.com/repos/edge stable InRelease [3,569 B]
Ign:6 https://ppa.launchpadcontent.net/jonathonf/ffmpeg-4/ubuntu jammy InRelease
Get:7 https://packages.microsoft.com/repos/edge stable/main amd64 Packages [8,803 B]
Err:8 https://ppa.launchpadcontent.net/jonathonf/ffmpeg-4/ubuntu jammy Release
404 Not Found [IP: 2620:2d:4000:1::3e 443]
0% [Waiting for headers]

solution

sudo rm -rf /var/lib/apt/lists/* 
sudo rm -rf /var/lib/apt/lists/partial/*
cd /var/cache/apt/archives  
sudo rm -rf partial

The above commands clear the cache files.

If you still encounter waiting for headers after clearing the cache file, replace the domestic source

#备份现有源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 

#查看当前版本
cat /etc/issue  

#修改文件,替换下面软件源,删除文件所有内容,替换对应版本的源,见Ubuntu国内源
sudo vim /etc/apt/sources.list 

#更新列表
sudo apt-get update 

In sudo vim /etc/apt/sources.listthis step, comment out all the contents. As follows: add in the place that
insert image description here
was not hit before .##

Then add at the front: (Note that my version is ubuntu-22.04, and the rest of the versions can be found in the link below. Or you can try it.)

deb http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse

Ubuntu mirror use help: https://mirrors.163.com/.help/ubuntu.html

You're done!

Guess you like

Origin blog.csdn.net/qq_45934285/article/details/132163660