#How To Reset Your Forgotten Linux Password in WSL – CloudSavvy IT

“#How To Reset Your Forgotten Linux Password in WSL – CloudSavvy IT”

Roman Samborskyi/Shutterstock

Forget your Windows Subsystem for Linux user password and you’ll be locked in a loop. To reset your password … you need to know your password. Here’s how to escape from that cycle.

Locked in an Endless Loop

An ouroboros is an ancient symbol depicting a serpent or dragon that’s eating its own tail. If you forget your Windows Subsystem for Linux (WSL) user’s password, you’ll find yourself locked in an equally unpleasant and endless loop.

The first time you launch a newly installed Linux distribution under the WSL, you’re asked to provide a user name and a password. This is your user password. In a normal Linux installation, you’re asked for your password each time you log in. With the WSL however, your user is logged in automatically and you’re taken straight to the Linux command prompt.

Because you don’t need to use your password to log in, it is easy for it to slip from your mind. Especially if you don’t use the WSL frequently.

That might not appear to be such a setback because, after all, you’re automatically logged in. The problem becomes apparent when you try to access files that are not within your home directory, or install software, or perform administrative activities like creating and managing other users.

To do those things you need to use the sudo command. In Linux, you prove you are authorized to use the sudo command by providing your password.

The obvious answer is to reset your password. You’ve forgotten it, so just set a new one, right? That’s a great idea. But the passwd command requires your current password to prove you’re you. It’s a sensible security measure. The passwd command requires proof that you’re the owner of the user account that you’re changing the password for before it lets you go ahead and change the password.

If you use sudo with the passwd command you can change the password for any user whether you know their password or not. That sounds like a solution, but we’re still thwarted because to use the sudo command you need to know your password. This is starting to feel like an ouroboros and a Catch-22 combined.

There are ways to escape this circular logic puzzle, of course. Here are two you can try.

Resetting With the Linux Executable

We’re going to show you two ways to do this. One way is a little more involved than the other, but it has worked every time we’ve tried it. The other way is a slightly simpler method but we’ve had mixed results with it.

We need to identify the executable file for the Linux distribution you’re using with the WSL. On Windows 10 it’ll be in this directory:


Replace “<username>” with the name of your Windows user account. At a Windows command prompt, change directory into this location, then type “dir.”


dir in a command window

The executable should be easy to identify. On this test machine, we’ve installed Ubuntu 20.04, and the “ubuntu2004.exe” file is evidently what we’re looking for.

We’ll start an Ubuntu session but tell it to log in as the root user instead of the user account you created when you installed the Linux distribution.

ubuntu2004 config --default-user root

An Ubuntu session is started and we’re presented with the command prompt in a terminal window. The prompt is in white text and the final character is a hash “#” not a dollar “$” sign. That tells us that the user is the root user and not a regular user. The user name also spells out “root.”

If further proof were required, we can use the whoami command.


So, we’re definitely logged in as root. We can go ahead and reset the default user’s password. The passwd command will ask you for their new password, and then ask you to enter it a second time. Neither one will echo to the screen. The password we’re changing belongs to the user “dave.”

passwd dave

Make sure you remember what the new password is. We’ll exit from the Ubuntu session and return to the Windows command prompt.


To test our new password we need to start a new Ubuntu session and reset the regular user account as the default account.

ubuntu2004 config --default-user dave

The session starts and we’re logged in as the regular user, with our usual colored command prompt.


To prove our password has been changed we’ll use the sudo command on a command. The command we use doesn’t matter, it’s the fact that we’re using sudo that is important. We’ll use the ps command to list some processes.

sudo ps -e

You’ll be prompted for the password you created when you used the passwd command as root. The password should be accepted, and the command should be launched for you.

Resetting With the wsl Command

We can accomplish the same thing using the WSL command. In our testing, we experienced inconsistent results but you might have more luck than we did. This is a shorter method, so you might want to try this first and if it doesn’t work for you try the longer method we’ve shown you above.

At a Windows command prompt, type:

wsl --user root

wsl --user root in a command window

A Linux session will start. You will be logged in as root. You can verify this by using the whoami command.


To reset the forgotten user password, use the passwd command and provide the name of the user account.

passwd dave

You’ll be asked to provide the new password twice. And that should be it.

If you log out of this session and start a new session you’ll be logged back in as the regular default account and you’ll have a new password.

Stop Chewing Your Tail

One or both of these techniques will work for you, and you’ll be freed from the endless cycle of not being able to reset your password because you don’t know your password.

If you liked the article, do not forget to share it with your friends. Follow us on Google News too, click on the star and choose us from your favorites.

For forums sites go to Forum.BuradaBiliyorum.Com

If you want to read more like this article, you can visit our Technology category.


Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button