Windows WSL(Windows Subsystem for Linux)中的 Ubuntu 密码重置
-
打开 PowerShell:以管理员身份运行 PowerShell。
-
查看可用的 WSL 发行版:
wsl -l
-
设置默认用户为 root:
使用以下命令,将 Ubuntu 的默认用户更改为 root:wsl -u root
-
启动 Ubuntu:输入以下命令启动 Ubuntu:
wsl
-
重置用户密码:
在 Ubuntu 中,使用以下命令重置你的用户密码(将your_username
替换为你的用户名):此处用rootpasswd your_username
-
退出并恢复默认用户:
输入exit
退出 Ubuntu,然后在 PowerShell 中将默认用户恢复为你原来的用户:ubuntu config --default-user your_username
完成这些步骤后,你应该能够使用新密码登录 Ubuntu。