1 开启Windows开发人员模式
步骤:在“开始”右键——“设置”——点击隐私和安全性——点击开发者选项——打开开发人员模式
2 启用Windows子系统功能
步骤:控制面板(图1位置查找)——程序——“程序和功能”下的“启用或关闭Windows功能”——勾选“适用于Linux的Windows子系统”,如图2,重启电脑即可
3 安装Linux虚拟机
步骤:点击“开始”——“Microsoft Store”——搜索“Ubuntu”——可选择任意版本以“Ubuntu20.04”为例——点击“获取”(获取之后就自动安装了)——点击“打开”
(不建议选择最新的,最新版一些库可能支持的还不是那么好,另外可能有一些潜在的缺陷;
LTS = Long Time Support 长时间支持版本的意思)
点击“打开”之后,可能遇到的问题:
(WslRegisterDistribution failed with error: 0x800701bc…)即“WSL安装无法打开”
造成该问题的原因是WSL版本由原来的WSL1升级到WSL2后,内核没有升级,升级文件放在下方,下载安装即可正常使用WSL了。下载链接: https://wslstorestorage.blob.core.windows.net/wslblob/wsl update x64.msi
涉及的步骤:双击安装,点击next即可,最后点击finish
4 继续点击“打开”,则出现如下界面
Installing, this may take a few minutes…
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: **zsyzl**(自己输入)
可能遇到问题:dduser: Please enter a username matching the regular expression configured via the NAME_REGEX[_SYSTEM] configuration variable. Use the `–force-badname’ option to relax this check or reconfigure NAME_REGEX.
解决方案:将首字母改为小写字母即可]
New password:(自己键盘输入,但是不可见)
Retype new password:(输入与上述密码相同即可)
passwd: password updated successfully
Installation successful!
适用于 Linux 的 Windows 子系统现已在 Microsoft Store!
你可以通过运行 “wsl.exe --update” 进行升级 或通过访问 https://aka.ms/wslstorepage
从Microsoft Store安装 WSL 将提供最新的 WSL 更新, faster.
有关详细信息,请访问 https://aka.ms/wslstoreinfo<
To run a command as administrator (user “root”), use “sudo ”.
See “man sudo_root” for details.
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.10.16.3-microsoft-standard-WSL2 x86_64)
- Documentation: https://help.ubuntu.com
- Management: https://landscape.canonical.com
- Support: https://ubuntu.com/advantage
System information as of Mon Nov 6 11:45:01 CST 2023
System load: 0.0 Processes: 8
Usage of /: 0.5% of 250.98GB Users logged in: 0
Memory usage: 2% IPv4 address for eth0: 172.30.85.168
Swap usage: 0%
Expanded Security Maintenance for Applications is not enabled.
0 updates can be applied immediately.
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
This message is shown once a day. To disable it please create the
/home/zsyzl/.hushlogin file.
zsyzl@DESKTOP-9NIMP6P:~$
以上步骤即安装完成WSL
首先“开始”——搜索并点击“powershell” ——输入“bash”即可打开wsl