Help! I forgot my WSL password
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)
- Open Command Prompt (Hit
Windows key
on your keyboard and type incmd
) - following steps are executed in the Command Prompt - Run
wsl whoami
to get your WSL username - Run
wsl --user root
- Run
passwd <your-username>
and enter a new password for your user - Run
logout
or hitCtrl
+D
(will log out as root) - Now your password has been changed
In case you have multiple WSL distros installed
- Open Command Prompt (Hit
Windows key
on your keyboard and type incmd
and launchCommand Prompt
by hittingEnter
) - following steps are executed in the Command Prompt - Run
wsl --list
to get your WSL distribution name - the list shows distribution names inUbuntu-22.04
format, but for the next steps you have to transform it into e.g.ubuntu2204
(replace<your-distro-name>
with this) - Run
<your-distro-name> run whoami
to get your WSL username - Run
<your-distro-name> run --user root
- Run
passwd <your-username>
and enter a new password for your user - Run
logout
or hitCtrl
+D
(will log out as root) - 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:
Let me know what you think of this article on twitter @niklas1e or leave a comment below!
Latest Articles
- Syntax highlighting in less March 2, 2024
- Satoshi Nakamoto potentially solved the crypto trilemma March 24, 2023
- Help! I forgot my WSL password September 19, 2022
- Why my Bash script ran in yarn/npm is throwing errors? February 8, 2022
- Due diligence: Beaxy February 13, 2021
- more...