解决Wsl2中Ubuntu无法更新软件的问题

用户在Ubuntu的WSL2环境中尝试更新软件源时遇到404错误,尝试了阿里云和清华大学的镜像源均未成功。最终,通过切换到中国科学技术大学的镜像源成功更新了软件源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文排版不太好,详情可见笔记 有道云笔记

安装wsl2之后,在Ubuntu中更新软件,执行apt-get update命令报错,如下

root@jiangcheng01:~# sudo apt-get update Ign:1 http://mirrors.aliyun.com/ubuntu groovy InRelease Ign:2 http://mirrors.aliyun.com/ubuntu groovy-security InRelease Ign:3 http://mirrors.aliyun.com/ubuntu groovy-updates InRelease Ign:4 http://mirrors.aliyun.com/ubuntu groovy-backports InRelease Err:5 http://mirrors.aliyun.com/ubuntu groovy Release 404 Not Found [IP: 124.239.239.226 80] Err:6 http://mirrors.aliyun.com/ubuntu groovy-security Release 404 Not Found [IP: 124.239.239.226 80] Err:7 http://mirrors.aliyun.com/ubuntu groovy-updates Release 404 Not Found [IP: 124.239.239.226 80] Err:8 http://mirrors.aliyun.com/ubuntu groovy-backports Release 404 Not Found [IP: 124.239.239.226 80] Reading package lists... Done E: The repository 'http://mirrors.aliyun.com/ubuntu groovy Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'http://mirrors.aliyun.com/ubuntu groovy-security Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'http://mirrors.aliyun.com/ubuntu groovy-updates Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'http://mirrors.aliyun.com/ubuntu groovy-backports Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. root@jiangcheng01:~# sudo vim /etc/apt/sources.list root@jiangcheng01:~# sudo apt-get update Ign:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy InRelease Ign:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-updates InRelease Ign:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-backports InRelease Ign:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-security InRelease Err:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy Release 404 Not Found [IP: 101.6.15.130 443] Err:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-updates Release 404 Not Found [IP: 101.6.15.130 443] Err:7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-backports Release 404 Not Found [IP: 101.6.15.130 443] Err:8 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-security Release 404 Not Found [IP: 101.6.15.130 443] Reading package lists... Done E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-updates Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-backports Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-security Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. root@jiangcheng01:~# apt-get update Ign:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy InRelease Ign:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-updates InRelease Ign:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-backports InRelease Ign:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-security InRelease Err:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy Release 404 Not Found [IP: 101.6.15.130 443] Err:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-updates Release 404 Not Found [IP: 101.6.15.130 443] Err:7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-backports Release 404 Not Found [IP: 101.6.15.130 443] Err:8 https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-security Release 404 Not Found [IP: 101.6.15.130 443] Reading package lists... Done E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-updates Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-backports Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu groovy-security Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. root@jiangcheng01:~# apt-get install xvfb Reading package lists... Done Building dependency tree... Done Reading state information... Done E: Unable to locate package xvfb root@jiangcheng01:~# sudo vim /etc/apt/sources.list root@jiangcheng01:~# apt-get update Ign:1 http://cn.archive.ubuntu.com/ubuntu groovy InRelease Ign:2 http://security.ubuntu.com/ubuntu groovy-security InRelease Ign:3 http://cn.archive.ubuntu.com/ubuntu groovy-security InRelease Ign:4 http://cn.archive.ubuntu.com/ubuntu groovy-updates InRelease Err:5 http://security.ubuntu.com/ubuntu groovy-security Release 404 Not Found [IP: 185.125.190.39 80] Err:6 http://cn.archive.ubuntu.com/ubuntu groovy Release 404 Not Found [IP: 91.189.91.38 80] Err:7 http://cn.archive.ubuntu.com/ubuntu groovy-security Release 404 Not Found [IP: 91.189.91.38 80] Err:8 http://cn.archive.ubuntu.com/ubuntu groovy-updates Release 404 Not Found [IP: 91.189.91.38 80] Reading package lists... Done E: The repository 'http://security.ubuntu.com/ubuntu groovy-security Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'http://cn.archive.ubuntu.com/ubuntu groovy Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'http://cn.archive.ubuntu.com/ubuntu groovy-security Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'http://cn.archive.ubuntu.com/ubuntu groovy-updates Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.

替换阿里镜像和清华镜像都不管用,最终替换为中科大镜像成功更新了软件源。

### 如何在 WSL2Ubuntu 22.04 上安装第三方软件 #### 更新系统包列表并升级现有软件 为了确保所有后续安装顺利进行,建议先更新本地的APT包索引文件,并将已安装的软件包升级到最新版本: ```bash sudo apt-get update && sudo apt-get upgrade -y ``` #### 安装基础工具 对于大多数第三方软件来说,`curl`, `wget`, 和 `gnupg` 是常用的下载和验证工具。如果尚未安装这些工具,则可以执行如下命令来获取它们[^1]。 ```bash sudo apt-get install curl wget gnupg -y ``` #### 添加外部仓库或PPA(个人包档案) 许多第三方应用程序可能不在官方Ubuntu存储库中。此时可考虑添加来自社区维护者或其他可信源提供的PPAs: ```bash sudo add-apt-repository ppa:some/ppa-name sudo apt-get update ``` 注意替换上述命令中的`ppa:some/ppa-name`为实际要添加的具体PPA地址。 #### 使用 APT 安装软件 一旦准备就绪,就可以通过APT轻松安装所需的程序了。只需知道确切的名字即可: ```bash sudo apt-get install software_name -y ``` 这里同样需把`software_name`替换成目标应用的确切名称。 #### 下载二进制文件手动安装 有些情况下,特别是针对闭源商业产品或是较新的开源项目,可以直接从官方网站下载预编译好的Linux版`.deb`包或者压缩后的二进制文件来进行离线安装。例如,假设有一个名为example.deb的Debian格式安装包,那么可以用下面的方法完成安装过程: ```bash cd /path/to/downloaded/file/ sudo dpkg -i example.deb # 如果遇到依赖关系错误,运行此命令解决 sudo apt --fix-broken install ``` 对于tarball形式发布的软件,解压后通常会提供详细的README文档指导用户如何继续操作。 #### 配置环境变量 (如有必要) 部分大型框架如Java、Python虚拟环境等,在安装完成后还需要配置PATH等环境变量以便全局调用其命令行工具。编辑用户的shell profile文件(比如.bashrc,.zshrc),加入相应路径设置语句。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值