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
- Opening the command prompt or terminal in PowerShell mode.
- 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
- Launch the WSL distribution (e.g. Type
ubuntu
in Command Prompt) - 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:
- 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.
- Login as root with
$ wsl -d Ubuntu-22.04 -u root
- Reset by:
$ passwd <your_username>
- 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. :)