官方文档: https://docs.microsoft.com/zh-cn/windows/wsl/
1.启用Windows10子系统功能
在控制面板-启用或关闭Windows功能中设置启用适用于Linux的Windows子系统,重启系统。
2.安装子系统
1.通过应用商店下载安装;
官方文档:https://docs.microsoft.com/zh-cn/windows/wsl/install-win10
2.通过手动下载进行安装;
官方文档:https://docs.microsoft.com/zh-cn/windows/wsl/install-manual
安装通过Windows PowerShell执行命令:Add-AppPackage 包名
3.启动子系统
查看系统安装的子系统:wsl -l
启动子系统:
- 通过安装的子系统终端打开;
- 通过命令打开,例如ubuntu 20.04可以在Windows终端执行 ubuntu2004 进入子系统。
4.创建用户
启动子系统后,系统会要求创建用户。根据系统提示创建用户名,密码。
官方文档:https://docs.microsoft.com/zh-cn/windows/wsl/user-support
5.修改源
wsl 中执行: sudo vi /etc/apt/sources.list
在文件末尾添加:
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
文件保存后更新源,执行命令:sudo apt update && sudo apt upgrade