成功解决ubuntu-22.04的sudo apt-get update一直卡在【0% [Waiting for headers]】

成功解决ubuntu-22.04的sudo apt-get update一直卡在【0% Waiting for headers】

问题描述

在下载安装包的时候一直卡在0% Waiting for headers,报错信息如下:

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

解决方案

python 复制代码
sudo rm -rf /var/lib/apt/lists/* 
sudo rm -rf /var/lib/apt/lists/partial/*
cd /var/cache/apt/archives  
sudo rm -rf partial

以上命令都是清理缓存文件。

如果清除缓存文件之后还是遇到waiting for headers,那就更换国内源

python 复制代码
#备份现有源
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 

即在sudo vim /etc/apt/sources.list的这一步,将其中的内容全部注释掉。如下:

在前面没打#的地方加上#。

然后在最前面加上:(注意我的版本是ubuntu-22.04,其余版本参加下面链接。或者试一下也可以。)

python 复制代码
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镜像使用帮助:https://mirrors.163.com/.help/ubuntu.html

大功告成!

相关推荐
半仙白桑11 分钟前
内核篇第十五讲:system-V共享内存
linux·共享内存·shmget·shmat·shmdt·shmctl
一条破秋裤28 分钟前
Linux 线程创建:pthread_create 与基本回收
java·linux·运维
阿钱真强道1 小时前
15 嵌入式操作系统 | 库的下载、编译、安装与验证(libubox / ubus / uci)
ubuntu·cmake·uci·ubus·libubox
s6516654962 小时前
IDT和GDT是什么
linux
Android系统攻城狮2 小时前
Linux Gstreamer深度解析之gst_audio_decoder_set_estimate_rate调用流程与实战(四十五)
linux·gstreamer音视频·音视频进阶
FED_AF2 小时前
Linux运维“邪修”功法之通配符
linux·运维
箓维2 小时前
线程的概念和理解
linux
云杂项3 小时前
tmux指南:安装、配置与高效使用(Ubuntu上)
linux·服务器·ubuntu
YOLO数据集集合3 小时前
风机叶片表面损伤检测数据集 | 风机叶片 表面损伤 污渍检测 无人机巡检 风电运维9119期
运维·人工智能·计算机视觉·目标跟踪·无人机·智慧城市·电力巡检
艸肅3 小时前
Ubuntu 安装 JDK (含手动安装)
java·ubuntu·jdk