Resetting Password for user account when you are using WSL(Windows Subsystem for Linux)

Mahek GorMahek 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:

  1. Right-click the Start button and select "Windows PowerShell (Admin)" or "Command Prompt (Admin).

  2. 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
  1. 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
  1. 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>
  1. 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>
  1. 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

Mahek Gor
Mahek Gor