Uh oh! Forgot your WSL password? Don't sweat it! I'll get you back in and running in no time.
Important notes before proceeding:
- Back up all your WSL data: If possible, back up your important files and data from your WSL before proceeding, as this process may involve making changes that could potentially lead to data loss.
- Understand the risks: Resetting a password involves granting temporary root access to your WSL system. Be cautious and follow the steps carefully to avoid unintended consequences.
Follow these steps to reset your forgotten WSL password:
Steps to Reset Your WSL Password:
Open Windows Command Prompt:
Type in wsl -l
This command will list all the Linux distributions you have installed.
Select the Linux Distribution:
From the list, select the Linux distribution you want to change the password for and type:
wsl-distribution config --default-user root
NB: Type it in lowercase and remove all spacing, hyphens (-
), and full stops (.
).
This command will allow you to change the password of your sudo user.
Now, Open Your WSL Terminal:
You will be logged in as the root user by default.
Type in: passwd username
to Change the Password
Restore the Default User:
Once the password is successfully changed, go back to the Windows Command Prompt and set the default user to its previous state by typing in:
wsl-distribution config --default-user your-username
Now, you can use your new password to perform sudo operations on your WSL.
Top comments (0)