I suddenly forgot the WSL user password, which made it impossible to execute the sudo command and even download and install the software.
The solution is simple:
-
Check your specific release version of WSL
Win + X
shortcut keys to run the administrator modepowershell
PS C:\WINDOWS\system32> wslconfig /l 适用于 Linux 的 Windows 子系统分发版: docker-desktop-data (默认) docker-desktop Ubuntu
The name of the distribution that I got here is
Ubuntu
-
root
Enter the WSL system as the userPS C:\WINDOWS\system32> wsl.exe -d Ubuntu --user root Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.10.16.3-microsoft-standard-WSL2 x86_64) ...
-
Reset user password (my username here is abc)
root@FK-ThinkPad:/mnt/c/WINDOWS/system32# passwd abc New password: Retype new password: passwd: password updated successfully