Force Reset WSL2 Password in Windows

DevOps19-02-2025

When I was doing some DevOps tasks, I tried to install some ca-certificates locally but then, for some reason, my password is not working. I tried variants of it but did not succeed.

Following the Guidelines Online

Of course I have to research it, even thought there is ChatGPT/Gemini/Copilot or whatever AI platform available out there.

Switch to “root” user

  1. Opening the command prompt or terminal in PowerShell mode.
  2. Run $ ubuntu config --default-user root. This will set the default user to “root”. For other distributions, the command might differ slightly. You can find the specific command in the distribution’s description in the Windows Store.

Reset the password

  1. Launch the WSL distribution (e.g. Type ubuntu in Command Prompt)
  2. Once logged in as root, reset the password for your user account using the passwd command: $ passwd <your_username>

Switch back to your normal user

After resetting the password, set the default user back to your normal user account. For Ubuntu, the command would be: $ ubuntu config --default-user <your_username>

Another Blocker

I tried running ubuntu config --default-user root and got an error:

'ubuntu' is not recognized as an internal or external command, operable program or batch file.

Research and Retry

After the error, had to search again and try by listing the distributions installed.

What I did was:

  1. Identify the correct command for your distribution: $ wsl -l -v

I got…

NAME                    STATE           VERSION
* Ubuntu-22.04            Stopped         2
  docker-desktop          Stopped         2
  rancher-desktop-data    Stopped         2
  docker-desktop-data     Stopped         2
  rancher-desktop         Stopped         2
  Ubuntu                  Stopped         2

The one with the wildcard is the active one.

  1. Login as root with $ wsl -d Ubuntu-22.04 -u root
  2. Reset by: $ passwd <your_username>
  3. Then logout or just press CTRL + D in your keyboard.

This should help you reset your password in WSL2.

If you like this quick guide, consider sharing or donating. Thanks. Give a shoutout via Twitter. :)

Author's photo

Herman Menor, Jr.

I'm a traveler, foodie, gamer, baller and trader viewed as a Web Developer and Software Engineer.

See other articles:

undefinedThumbnail

Solving Windows and WSL2 DNS Problem

WSL2 is a feature in Windows allowing users to run Linux directly on their Windows machines, improving performance and compatibility

DevOps22-01-2024

undefinedThumbnail

Ansible Testing Practice

DevOps is already part of my tasks as an experienced Software Engineer and Web Developer. Here are some practice to test your Ansible script.

DevOps25-10-2023