在Windows11中安装WSL的记录
一、WSL简易安装
win+r
打开运行,输入cmd
并回车
> wsl --install %安装wsl,默认是Ubuntu发行版%
请求的操作需要提升。
正在安装: 虚拟机平台
已安装 虚拟机平台。
正在安装: 适用于 Linux 的 Windows 子系统
已安装 适用于 Linux 的 Windows 子系统。
正在安装: Ubuntu
已安装 Ubuntu。
请求的操作成功。直到重新启动系统前更改将不会生效。
重启以后,再次执行安装命令
> wsl --install %安装wsl,默认是Ubuntu发行版%
Ubuntu 已安装。
正在启动 Ubuntu...
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370114
Error: 0x80370114 ??????????????????
Press any key to continue...
设置
→ 应用
→可选功能
→更多Windows功能
,启用适用于Linux的Windows子系统
。
第三次执行安装命令,并设置用户名(小写开头)与密码,成功!!!
> wsl --install
Ubuntu 已安装。
正在启动 Ubuntu...
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: Rick
adduser: 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.
Enter new UNIX username: rick
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.90.1-microsoft-standard-WSL2 x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
This message is shown once a day. To disable it please create the
/home/rick/.hushlogin file.
rick@DESKTOP-4FVEAKU:~$ #自动进入Linux的命令行
二、检查正在运行的WSL版本
> wsl -l -v
NAME STATE VERSION
* Ubuntu Running 2
默认是WSL2
三、运行WSL
> ubuntu # 运行已安装的发行版名称
或者
> wsl # 运行默认的Linux发行版