Somethimes I don't use WSL on my main machine for long periods of time and I forget the user password, so I've done this more than once.
Step 1:
Open a command prompt as administrator.
Get the Name of the WSL installation
wsl --list --verbose

Step 2: Set default user as root
So using the distribution name from above, mine is Debian, you would run this
Debian config --default-user root
Next start-up the distribution by typing the name again, and double check that it worked with the whoami command.

Step 3: Change the User Password
Now you change the password of the user like you would for any distro with:
passwd jeff
Because jeff is my username in this case.

Step 4: Put everything back into place and test
Now you need to put the proper user in for default and you are done.

Comments