当前位置: 代码网 > 服务器>服务器>Linux > WSL不同版本的Ubuntu更换清华镜像,加速Ubuntu软件下载速度

WSL不同版本的Ubuntu更换清华镜像,加速Ubuntu软件下载速度

2024年08月03日 Linux 我要评论
使用WSL跑深度学习挺不错的,但是用wsl安装linux软件可能会存在部分问题,由于WSL里面的Ubuntu软件仓库是默认的源,有时候可能会造成网络连接问题,或者下载速度很慢,更换为清华镜像或者阿里云镜像会带来Ubuntu软件的快速下载,优化软件使用体验。Ubuntu的系统自带的配置文件在/etc/apt/source.list中,因此我们需要首先备份该配置文件,否则删了的话,如果镜像镜像也不可用,就很难受了。现在的win都是64位的,对应的WSL几乎都是64位的,因此对大多人都是适应的。

不同版本的ubuntu使用清华镜像,加速ubuntu软件下载速度

本博客目的: wsl的ubuntu软件仓库更换清华镜像源。
提示: 这个是更新ubuntu的软件仓库,而不是pip、conda更换清华镜像,记得自己的目的,别看错了。

使用wsl跑深度学习挺不错的,但是用wsl安装linux软件可能会存在部分问题,由于wsl里面的ubuntu软件仓库是默认的源,有时候可能会造成网络连接问题,或者下载速度很慢,更换为清华镜像或者阿里云镜像会带来ubuntu软件的快速下载,优化软件使用体验。

清华大学开源软件镜像站:https://mirrors.tuna.tsinghua.edu.cn/

清华大学ubuntu软件仓库:https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/

阿里云ubuntu软件仓库:https://developer.aliyun.com/mirror/ubuntu

该镜像仅包含32/64位x86架构处理器的软件包,在在 arm(arm64, armhf)、powerpc(ppc64el)、risc-v(riscv64) 和 s390x 等架构的设备上(对应官方源为 ports.ubuntu.com)请使用 ubuntu-ports 镜像

现在的win都是64位的,对应的wsl几乎都是64位的,因此对大多人都是适应的。

1. 备份源软件配置文件

ubuntu的系统自带的配置文件在/etc/apt/source.list中,因此我们需要首先备份该配置文件,否则删了的话,如果镜像镜像也不可用,就很难受了。

首先进入配置文件目录,如下命令:

cd /etc/apt

在这里插入图片描述

备份的命令如下,sudo表示启用管理员权限,cp表示复制,就是把后面的sources.list文件复制一份,复制的文件以source.list.bak命名。

sudo cp sources.list sources.list.bak

在这里插入图片描述

2. 复制镜像源

因为不同的ubuntu版本对应的镜像是不同的,所以需要复制的命令也不一致,大家可以根据自己的ubuntu版本来复制命令。他们的命令是很相似的,区别就是括号里面不一样。点击下面挑战链接,复制对应的镜像源配置。镜像速度的话,这个看地区差异,不太好说。

ubuntu22.04 清华镜像源链接

ubuntu23.04 清华镜像源链接

ubuntu22.10 清华镜像源链接

ubuntu20.04 清华镜像源链接

ubuntu18.04 清华镜像源链接

ubuntu16.04 清华镜像源链接

ubuntu22.04 阿里云镜像

ubuntu20.04 阿里云镜像

ubuntu软件仓库:

ubuntu 22.04 lts (jammy)镜像源:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse

ubuntu 23.04 (lunar) 镜像源:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ lunar-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ lunar-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ lunar-proposed main restricted universe multiverse

ubuntu 22.10 (kinetic):

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ kinetic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ kinetic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ kinetic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ kinetic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ kinetic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ kinetic-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ kinetic-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ kinetic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ kinetic-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ kinetic-proposed main restricted universe multiverse

ubuntu 20.04 (focal):

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

ubuntu 18.04 (bionic):

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

ubuntu 16.04 (xenial) :

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse

阿里云ubuntu 22.04 软件仓库:

deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

阿里云ubuntu 20.04 软件仓库:

deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

3. 修改软件源配置文件

使用如下命令打开配置文件:

sudo vim source.list

打开该文件之后,使用命令ggdg将该文件内容删除,然后按a键编辑,把复制过来的清华镜像直接右键就可粘贴。

如下所示。

保存的话,需要切换到英文输入,先esc,然后冒号:,再按wq保存退出即可。

在这里插入图片描述

4. 更新软件包列表,升级软件包等内容

更新软件包列表代码如下,可以看到get的地址是阿里云的镜像。

sudo apt-get update

在这里插入图片描述

升级软件包如下命令:

sudo apt-get upgrade

在这里插入图片描述

5. 从仓库中下载其它软件

直接使用命令sudo apt-get install xxx就可以安装对应的xxx软件,

如下所示:

sudo apt-get install gedit
可能存在的问题

现在的清华镜像ubuntu软件仓库,我使用学校教育网无法连接,不知道是因为我的ip问题,还是清华镜像仓库暂时不可用的问题。

个人觉得是因为我的ip段被清华的ubuntu软件仓库拉黑了。。。

连接问题如下:

2 packages can be upgraded. run 'apt list --upgradable' to see them.
w: failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal/inrelease  cannot initiate the connection to mirrors.tuna.tsinghua.edu.cn:443 (2402:f000:1:400::2). - connect (101: network is unreachable) could not connect to mirrors.tuna.tsinghua.edu.cn:443 (101.6.15.130), connection timed out
w: failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-updates/inrelease  cannot initiate the connection to mirrors.tuna.tsinghua.edu.cn:443 (2402:f000:1:400::2). - connect (101: network is unreachable)
w: failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-backports/inrelease  cannot initiate the connection to mirrors.tuna.tsinghua.edu.cn:443 (2402:f000:1:400::2). - connect (101: network is unreachable)
w: some index files failed to download. they have been ignored, or old ones used instead.

因为使用清华镜像连接有错误,所以我现在使用阿里云镜像了。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com