If you are using windows with WSL Ubuntu and forgot the password, resetting it would be a hassle. However, you can reset the password without reinstalling the distro or losing the data. This is a step-by-step guide to reset a forgotten password in Ubuntu WSL running on windows and not a guide to cause harm in any form. Please follow this guide if you:
Forgot password without use for long period
Setup random password accidentally
Here is the Step-by-Step guide to reset your Ubuntu WSL password running on windows.
Open CMD or PowerShell as an Administrator.
Click Start or press windows button
Type cmd or powershell to search
Right click and select Run as administrator.
List your installed Linux distributions
wsl -l -vExample:
NAME STATE VERSION * Ubuntu running 2Launch WSL as root user
Type exact name of your ubuntu distribution (Ubuntu in my case it might be Ubuntu-24.0)
wsl -d Ubuntu -u rootFigure out your username (if you know your username, skip this step)
ls /homeReset your password
passwd yourusernameReplace yourusername with above output or your known username
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfullyEnter new password and complete the process.
Hope you have successfully reset your password. If you have any problem, feel free to contact me.












