I have installed the Linux Bash on Windows 10(which is available in recent update from Microsoft), but it's been long I happened to forgot my password now.

I have checked many websites and all it says is to go through the booting option where it will not work in this case as this is Windows system.

How can I get to reset my password?

  • 3
    Which password did you lose exactly? Your Windows account password? – David Foerster Aug 6 '16 at 12:08
  • an example "booting option" would be to boot to single user mode by setting kernel cmdline to "single" via grub. For those curious. – kevinf Jun 28 '17 at 16:53
  • 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.)

  • 6
    lxrun is for beta version of WSL. If you install ubuntu from the app store, the command is ubuntu config --default-user root. – Endy Tjahjono Nov 19 '17 at 9:13
  • 2
    Yeah, this is an alternative way but I got the error: Failed to set default user to: root. – Kirby Dec 17 '17 at 7:47
  • 2
    @Kirby: you must log out from the WSL shell before running the command in the Windows command prompt. – dr01 Mar 22 at 9:16
  • I tried "ubuntu config --default-user root", and got an error says "ubuntu is not recognized as an internal or external command, operable program or batch file" – Indominus Jun 3 at 20:31
  • 1
    I kept getting Error: 0x80070057 The parameter is incorrect, so I ended up following @dr01 's cue and ran ubuntu in PowerShell, then logout, then configured the default user again. Success 👍 – skia.heliou Jun 7 at 13:42

The above did not work. Even after changing default user, the bash always opened with my user. So instead this worked:

  1. edit file (in notepad or notepad++):

  2. find your normal user, for example:


    and simply remove the hash part (below part)


    you will see a different hash - I hope :), so should look like:

  3. Save the file

  4. start bash again
  5. sudo bash
  6. password this will ask for your new password without requiring previous one.
  • 5
    this works but the official directory is now similar to %localappdata%\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\etc\shadow – Mauro Destro Dec 21 '17 at 8:13
  • 4
    This is the best answer by far. To find the path to your shadow file you can use this PowerShell abomination: Get-ChildItem -Path C:\ -Filter shadow -Recurse -ErrorAction SilentlyContinue -Force which is an insanely verbose version of find /mnt/c/ -name shadow in both execution and results. No need for elevated privileges to edit the file, but make sure your bash window is closed before you do it. – Russ Jan 4 at 5:29
  • 1
    This is the winner! Worked great when the first answer did not. – Kim Mar 15 at 15:29
  • The accepted answer got me 'Error: 0x80070057 The parameter is incorrect.'. (and no, the console was not in legacy mode). This worked seamlessly; – Cristi Diaconescu May 24 at 10:00

To add to Tmu's answer, here's a Powershell script (gist) that automates the process (including automatically detecting the current default username)

# Resets the password for the default LXSS / WSL bash user
$lxssUsername = (Get-ItemProperty HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss).DefaultUsername
lxrun /setdefaultuser root
bash -c "passwd $lxssUsername"
lxrun /setdefaultuser $lxssUsername

protected by souravc Jun 16 '17 at 6:47

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.