Help! I forgot my WSL password

by on under Tech
2 minute read

Ok, I’m pretty sure I am not the only one who has set up their WSL (Windows Subsystem Linux) password and thought something like “yeah, I’ll surely remember this, it’s so simple and easy to remember”. Just to notice a couple weeks later you indeed forgot the password, because you didn’t use it actively. Also maybe because it was so easy (and at the same time different from other passwords?). Before judging me completely, I have to say that I do use credentials manager to keep my credentials in a good place. Then again, there’s times when you just think “meh, I don’t need to save this, it’s so simple” or simply forget to save it. Okay, okay, enough of rambling; let’s get to the point 😅

Notice! There’s also short video guides at the end of the post

Changing your WSL password for default distribution (or when you only have one distribution installed)

  1. Open Command Prompt (Hit Windows key on your keyboard and type in cmd) - following steps are executed in the Command Prompt
  2. Run wsl whoami to get your WSL username
  3. Run wsl --user root
  4. Run passwd <your-username> and enter a new password for your user
  5. Run logout or hit Ctrl+D (will log out as root)
  6. Now your password has been changed

In case you have multiple WSL distros installed

  1. Open Command Prompt (Hit Windows key on your keyboard and type in cmd and launch Command Prompt by hitting Enter) - following steps are executed in the Command Prompt
  2. Run wsl --list to get your WSL distribution name - the list shows distribution names in Ubuntu-22.04 format, but for the next steps you have to transform it into e.g. ubuntu2204 (replace <your-distro-name> with this)
  3. Run <your-distro-name> run whoami to get your WSL username
  4. Run <your-distro-name> run --user root
  5. Run passwd <your-username> and enter a new password for your user
  6. Run logout or hit Ctrl+D (will log out as root)
  7. Now your password has been changed

And here’s a recap in form of short videos

Reset sudo password in WSL:

Reset sudo password in WSL when you have multiple Linux distributions installed:

windows, linux, scripting
comments powered by Disqus