Reset Ubuntu Password in WSL on Windows 10

I recently wanted to install something within my Ubuntu shell and could not remember the password, and thought I was stuck. However, I found a way of resetting it quickly and easily.

  1. Open Bash on Ubuntu to take note of your Linux username (note that this may or may not match your Windows username)
  2. Close your bash session; you must do this for the following commands to work.
  3. Open a Windows command prompt as Admin
  4. Enter ubuntu config --default-user root to set the default user as root.
💡
If you find ubuntu is unrecognised as a command, try ubuntu2004 or swap the numbers to represent your version. 

5.   Now open your Ubuntu shell again.  This time you'll notice you are logged in as root.

6.   You now want to change the password of your account type, passwd [username] and follow the instructions to reset your password.  Close the Ubuntu shell.

7.   Now, you want to change your Ubuntu shell to make your profile the default user.  Within a Windows command prompt, run the following command ubuntu config --default-user [username]

When you open your Ubuntu shell, your profile will defaultto yours, and the password will be reset.

Enjoy!