How to reset password of your account in Windows Subsystem Linux.
You want to run a command which require priviledged account but you don't know what's your password `sudo <command>` is asking you...
One day, you have to run a command that require priviledged account and suddenly, you recognize that you don’t remember what’s your password. So the only choice is reset it to a new one, to do that, you need to login as `root` and change the password of your account. To do that, follow steps below:
Locate the executable file that start the Linux distro you’re using in WSL on your computer:
Change location to the folder of WSL excutable files, open cmd / terminal window and run below command:
`C:\>cd %LOCALAPPDATA%\Microsoft\WindowsApps`
Run below command to se which distro is defaule (in case you’re have mutliple distroes installed under WSL). It’s `C:\Users\Admin\AppData\Local\Microsoft\WindowsApps>`
in my case.
`C:\Users\Admin\AppData\Local\Microsoft\WindowsApps>wsl -l`
Now, saying that I want to reset my account in Ubuntu-22.04, need to find the excutable file of it by doing as below
`C:\Users\Admin\AppData\Local\Microsoft\WindowsApps>dir `
You can see file name `ubuntu2204.exe`
, now run it as below command:
`C:\Users\Admin\AppData\Local\Microsoft\WindowsApps>ubuntu 2204.exe config --default-user root`
This will start Ubuntu WSL as run under `root` account, once it up, you can change password for your user by use `passwd` command
After set new password for your account, exit WSL Ubuntu, back to Windows’s command line and run below command again to change default user of Ubuntu:
`C:\Users\Admin\AppData\Local\Microsoft\WindowsApps>ubuntu 2204.exe config --default-user myusr`
If you have any comments, please let me known.