Reset WSL2 Password to default

By jeff


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
Screenshot of where we are so far

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.

Screenshot showing that the user is root

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.

Change the password for the user.

Step 4: Put everything back into place and test

Now you need to put the proper user in for default and you are done.

and done.