Ubuntu – Reset the password in Ubuntu / Linux Bash in Windows

password-recoverywindows-subsystem-for-linux

I have installed Linux Bash on Windows 10 (available from Microsoft), but I've forgotten my password.

I've searched for a solution but I only find suggestions that involve doing something before the system boots, like accessing recovery mode, but that will not work in this case as this Ubuntu is just an application within a Windows system and doesn't have its own boot process.

How can I reset my password?

Best Answer

  • Run bash and make a note of your Linux username (this need not match your Windows username), see How can I find out my user name?
  • Close Bash on Ubuntu if it is running (or the next command will fail).
  • In Windows admin command prompt (Super+X, A) change the default user to root:

    ubuntu config --default-user root
    

If you are using Ubuntu 18.04 in WSL, the command has changed to ubuntu1804 , so

ubuntu1804 config --default-user root
  • Now Bash on Ubuntu on Windows logs you in as root without asking password
  • Use passwd command in Bash to change the user password (the user whose password you want to reset):

    passwd your_username
    
  • Change the default user back to your normal user in Windows command prompt

    ubuntu config --default-user  your_username
    

If you are using Ubuntu 18.04 in WSL, the command has changed to ubuntu1804 , so

ubuntu1804 config --default-user your_username

Watch Full Video to Recover your password Windows Subsystem Linux https://youtu.be/dTR232yvDCE

Note 1: The subsystem used in the video is not Ubuntu, but Kali Linux. Hence the difference in the command.

Note 2: If you are still using the original Ubuntu subsystem that came with the Anniversary Update, use the command lxrun. Upgrade to the subsystem version distributed via Microsoft Store is recommended.)

Related Question