DEV Community

Michael J Moraes
Michael J Moraes

Posted on

Reset WSL2 User Password

Considering tha you are using Ubuntu on Windows with WSL2.

Tips: If you dont know what is your WSL2 version, you discovery using powershell with the command: wsl -l

In my case, the return was ubuntu-20.04, remove the special characters e you will have the command for version like: ubuntu2004, i will call this of ubuntuversion.

Baby steps
1 - Change the default user to root.
-> Open PowerShell and type: ubuntuversion --default-user root

2 - Change your user password
-> Open your linux bash(your linux version)
-> You will see the user root identified
-> Type: passwd newpassword
-> Type your new password twice
-> Exit from bash

3 - Configuring the default WSL2 user for your user
-> Open PowerShell and type ubuntuversion --default-user username
-> Exit of PowerShell

4 - Testing
-> Open your WSL2 Linux bash and try typing sudo ls
-> Put your new password

5 - Enjoy
I´m Michael Jackson from CyberEduca - https://www.linkedin.com/in/michaeljmoraes

Top comments (0)