Resetting Password for user account when you are using WSL(Windows Subsystem for Linux)
Mahek Gor
1 min read
If you're using WSL (Windows Subsystem for Linux) and you've forgotten the password for your user account, you can reset it by following these steps:
Right-click the Start button and select "Windows PowerShell (Admin)" or "Command Prompt (Admin).
In the PowerShell window, list your installed WSL distributions with the following command. Note the name of your installed distribution (e.g., Ubuntu).
wsl --list --verbose
- Temporarily set the default user to
root
to bypass the password prompt. Replace<distro_name>
with the name of your installed distribution (e.g., Ubuntu).
wsl -d <distro_name> -u root
- This command will open the WSL distribution as the root user. Now, reset your password by running below command. Replace
<username>
with your actual WSL username. Follow the prompts to set a new password.
passwd <username>
- After resetting the password, set the default user back to your original user. Replace
<distro_name>
with the name of your installed distribution (e.g., Ubuntu) and<username>
with your WSL username.
wsl -d <distro_name> -u <username>
- Exit the WSL root shell and revert the default user.
exit
wsl -d Ubuntu -u your_username
Now you password is reset. You can now enter new password.
Thank you ! Keep Learning :)
0
Subscribe to my newsletter
Read articles from Mahek Gor directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by