WSL --Ubuntu-24.04-LTS子系统安装教程

bios打开虚拟化

打开Windows功能,打开"适用于Linux的Windows子系统"和"虚拟机平台"

打开powershell,输入

powershell 复制代码
wsl --install

下载完成后,在终端中输入

powershell 复制代码
wsl.exe -l -o

这条命令可以查看支持安装的linux发行版

这里用Ubuntu 24.04 LTS举例

输入

powershell 复制代码
wsl.exe --install Ubuntu-24.04

安装完成后会自动启动。注:这里的都是非桌面版

按照步骤设置用户名和密码即可

然后:

powershell 复制代码
#依次输入
cd /etc/apt
sudo vim sources.list
#注意:第二个命令需要输入的sudo密码就是前面设置过的那个
#输入
ggdG
#并且按下enter清空文本,然后黏贴以下内容,注释不建议删
powershell 复制代码
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse

# 以下安全更新软件源为官方源配置
deb http://security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse

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

最后按下esc然后输入:wq!并且按下enter即可

然后就可以使用了

关机系统就是确保子系统里没有进程了之后关掉窗口即可

打开系统的话...

在windows开始菜单的搜索栏里搜索"Ubuntu"并且打开就行...
点赞关注收藏

相关推荐
HalvmånEver2 小时前
MySQL数据库表(table)操作
linux·数据库·学习·mysql
月光下的麦克2 小时前
Ubuntu 与 Windows 之间文件互传
linux·运维·ubuntu
是垚不是土2 小时前
Kafka 故障排查周期长?试试 Kdoctor
linux·运维·分布式·ai·kafka·运维开发
野木香2 小时前
linux安装常用服务(不含jenkins)
linux·运维·jenkins
计算机安禾2 小时前
【Linux从入门到精通】第8篇:用户与权限管理(上)——谁动了我的文件?
linux·运维·服务器
艾莉丝努力练剑2 小时前
【Linux线程】Linux系统多线程(九):线程池实现(附代码示例)
linux·运维·服务器·c++·学习·架构
晨晖22 小时前
linux笔记6
linux·运维·笔记
艾莉丝努力练剑2 小时前
【Linux线程】Linux系统多线程(八):<策略模式>日志系统的封装实现
linux·运维·服务器·c++·学习·策略模式
HalvmånEver2 小时前
MySQL数据库操作
linux·数据库·学习·mysql