1.在C盘或者D盘新建一个文件夹,名为Linux(你也可以根据自己喜欢命名);
2.在搜索栏打开powershell,并在Linux文件夹下打开;
3.下载ubuntu20.04,在powershell界面输入
Invoke-WebRequest -Uri https://wsldownload.azureedge.net/Ubuntu_2004.2020.424.0_x64.appx -OutFile Ubuntu20.04.appx -UseBasicParsing
文件大概4G左右,稍等几分钟;
4.依次执行以下四项命令:
Rename-Item .\Ubuntu20.04.appx Ubuntu.zip
Expand-Archive .\Ubuntu.zip -Verbose
cd .\Ubuntu\
.\ubuntu2004.exe
5.提示The Windows Subsystem for Linux optional component is not enabled. Please enable it and try again,原因未安装Windows子系统支持。打开power shell输入:
wsl --install
此时提示,应关机重启生效。
wsl --list --online(这步可以不进行)
wsl --install -d Ubuntu-20.04(选择对应版本,这步可以不进行)
6. 查看wsl 版本(关机重启ubuntu报错:WslRegisterDistribution failed with error: 0x800701bc的情况下)并更新
wsl -l -v
下载适用于 x64 计算机的 WSL2 Linux 内核更新包:https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
直接安装即可。
7.在C或D:\Linux\Ubuntu文件夹打开ubuntu图标之后进入设置流程
用户名:正规命名方式请小写字母
新密码:一般六位数
确认新密码:同上
8.可以直接用了。