Reset the password in Ubuntu / Linux Bash in WindowsHow to change password using Windows version of...

How to generate globally unique ids for different tables of the same database?

Science-fiction short story where space navy wanted hospital ships and settlers had guns mounted everywhere

Have researchers managed to "reverse time"? If so, what does that mean for physics?

PTIJ: Who should pay for Uber rides: the child or the parent?

Can anyone tell me why this program fails?

Can the damage from a Talisman of Pure Good (or Ultimate Evil) be non-lethal?

Why would a flight no longer considered airworthy be redirected like this?

Why are the outputs of printf and std::cout different

2D counterpart of std::array in C++17

Replacing Windows 7 security updates with anti-virus?

SQL Server Primary Login Restrictions

An Accountant Seeks the Help of a Mathematician

Could the Saturn V actually have launched astronauts around Venus?

Humanity loses the vast majority of its technology, information, and population in the year 2122. How long does it take to rebuild itself?

How to simplify this time periods definition interface?

Instead of Universal Basic Income, why not Universal Basic NEEDS?

Can elves maintain concentration in a trance?

Calculus II Professor will not accept my correct integral evaluation that uses a different method, should I bring this up further?

In-house repeater?

Professor being mistaken for a grad student

Ban on all campaign finance?

Does this AnyDice function accurately calculate the number of ogres you make unconcious with three 4th-level castings of Sleep?

Does the statement `int val = (++i > ++j) ? ++i : ++j;` invoke undefined behavior?

How to deal with taxi scam when on vacation?



Reset the password in Ubuntu / Linux Bash in Windows


How to change password using Windows version of Ubuntu?How can I find out my user name?Password change doesn't persist after restartRecovering PasswordPassword recovery - usual options failHow do I reboot from the recovery console?How Do I Reset my Ubuntu Password on a Laptop That Came with Windows 8 Pre-installed?Reset Windows Password with Ubuntu Live CDSystem won't boot into recovery modeCan't access recovery mode, for dual booting comp, by holding shiftPassword doesn't work after upgrading Ubuntu 17.10 to 18.04I am not able to reset my Ubuntu adminstrative password













159















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?










share|improve this question




















  • 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
















159















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?










share|improve this question




















  • 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














159












159








159


77






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?










share|improve this question
















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?







password-recovery windows-subsystem-for-linux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 11 '18 at 7:59









Zanna

51k13138242




51k13138242










asked May 13 '16 at 22:19









Maheedhar K VMaheedhar K V

796254




796254








  • 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














  • 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








3




3





Which password did you lose exactly? Your Windows account password?

– David Foerster
Aug 6 '16 at 12:08





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





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










4 Answers
4






active

oldest

votes


















282















  • 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.)






share|improve this answer





















  • 7





    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 '18 at 9:16






  • 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 '18 at 13:42








  • 1





    If you installed ubuntu 18.04 on WSL, the command is ubuntu1804 instead of ubuntu. Hope this saves some head-scratching.

    – Indominus
    Jun 8 '18 at 3:43





















39














The above did not work. Even after changing default user, Bash always opened with my user.



So instead I did this, which worked:





  1. Edit this file (in notepad or notepad++):



    %localappdata%lxssrootfsetcshadow



  2. Find your normal user, for example:



    user1:$jsdjksadgfhsdf.saflsdf.sadf.safd:17299:0:99999:7:::


    and simply remove the hash part (below part)



    $jsdjksadgfhsdf.saflsdf.sadf.safd


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



    user1::17299:0:99999:7:::


  3. Save the file



  4. Start Bash again with root privileges and set your password



     sudo bash
    passwd <your-user-name>


    You can now set a new password without having to enter the previous one.








share|improve this answer





















  • 8





    this works but the official directory is now similar to %localappdata%PackagesCanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgscLocalStaterootfsetcshadow

    – Mauro Destro
    Dec 21 '17 at 8:13






  • 7





    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 '18 at 5:29








  • 1





    This is the winner! Worked great when the first answer did not.

    – Kim
    Mar 15 '18 at 15:29






  • 1





    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 '18 at 10:00






  • 1





    This answer worked exactly as outlined above. The first answer did not work for me.

    – Shanemeister
    Feb 20 at 15:01



















25














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:SOFTWAREMicrosoftWindowsCurrentVersionLxss).DefaultUsername
lxrun /setdefaultuser root
bash -c "passwd $lxssUsername"
lxrun /setdefaultuser $lxssUsername





share|improve this answer


























  • getting E r r o r : 0 x 8 0 0 7 0 0 0 2 in powershell

    – Nitin Sawant
    Mar 5 at 6:45



















0














For those of you who lost the root password, what worked for me, was updating to Ubuntu 18.04 LTS via the Windows Store. Note, the windows store has two distinct options:




  1. Ubuntu

  2. Ubuntu 18.04 LTS (Pick this one)


To check your current version, run the following as any user:



cat /etc-*release


You should see a line in the output that says:



DISTRIB_RELEASE=16.01


If you see that, then definitely update to 18.04, and it will prompt you to create new UNIX credentials.






share|improve this answer






















    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?














    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    282















    • 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.)






    share|improve this answer





















    • 7





      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 '18 at 9:16






    • 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 '18 at 13:42








    • 1





      If you installed ubuntu 18.04 on WSL, the command is ubuntu1804 instead of ubuntu. Hope this saves some head-scratching.

      – Indominus
      Jun 8 '18 at 3:43


















    282















    • 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.)






    share|improve this answer





















    • 7





      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 '18 at 9:16






    • 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 '18 at 13:42








    • 1





      If you installed ubuntu 18.04 on WSL, the command is ubuntu1804 instead of ubuntu. Hope this saves some head-scratching.

      – Indominus
      Jun 8 '18 at 3:43
















    282












    282








    282








    • 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.)






    share|improve this 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.)







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 8 '18 at 15:24









    Panther

    79.6k14158259




    79.6k14158259










    answered Aug 5 '16 at 10:02









    TmuTmu

    2,921164




    2,921164








    • 7





      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 '18 at 9:16






    • 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 '18 at 13:42








    • 1





      If you installed ubuntu 18.04 on WSL, the command is ubuntu1804 instead of ubuntu. Hope this saves some head-scratching.

      – Indominus
      Jun 8 '18 at 3:43
















    • 7





      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 '18 at 9:16






    • 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 '18 at 13:42








    • 1





      If you installed ubuntu 18.04 on WSL, the command is ubuntu1804 instead of ubuntu. Hope this saves some head-scratching.

      – Indominus
      Jun 8 '18 at 3:43










    7




    7





    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





    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




    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





    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




    2





    @Kirby: you must log out from the WSL shell before running the command in the Windows command prompt.

    – dr01
    Mar 22 '18 at 9:16





    @Kirby: you must log out from the WSL shell before running the command in the Windows command prompt.

    – dr01
    Mar 22 '18 at 9:16




    1




    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 '18 at 13:42







    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 '18 at 13:42






    1




    1





    If you installed ubuntu 18.04 on WSL, the command is ubuntu1804 instead of ubuntu. Hope this saves some head-scratching.

    – Indominus
    Jun 8 '18 at 3:43







    If you installed ubuntu 18.04 on WSL, the command is ubuntu1804 instead of ubuntu. Hope this saves some head-scratching.

    – Indominus
    Jun 8 '18 at 3:43















    39














    The above did not work. Even after changing default user, Bash always opened with my user.



    So instead I did this, which worked:





    1. Edit this file (in notepad or notepad++):



      %localappdata%lxssrootfsetcshadow



    2. Find your normal user, for example:



      user1:$jsdjksadgfhsdf.saflsdf.sadf.safd:17299:0:99999:7:::


      and simply remove the hash part (below part)



      $jsdjksadgfhsdf.saflsdf.sadf.safd


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



      user1::17299:0:99999:7:::


    3. Save the file



    4. Start Bash again with root privileges and set your password



       sudo bash
      passwd <your-user-name>


      You can now set a new password without having to enter the previous one.








    share|improve this answer





















    • 8





      this works but the official directory is now similar to %localappdata%PackagesCanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgscLocalStaterootfsetcshadow

      – Mauro Destro
      Dec 21 '17 at 8:13






    • 7





      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 '18 at 5:29








    • 1





      This is the winner! Worked great when the first answer did not.

      – Kim
      Mar 15 '18 at 15:29






    • 1





      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 '18 at 10:00






    • 1





      This answer worked exactly as outlined above. The first answer did not work for me.

      – Shanemeister
      Feb 20 at 15:01
















    39














    The above did not work. Even after changing default user, Bash always opened with my user.



    So instead I did this, which worked:





    1. Edit this file (in notepad or notepad++):



      %localappdata%lxssrootfsetcshadow



    2. Find your normal user, for example:



      user1:$jsdjksadgfhsdf.saflsdf.sadf.safd:17299:0:99999:7:::


      and simply remove the hash part (below part)



      $jsdjksadgfhsdf.saflsdf.sadf.safd


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



      user1::17299:0:99999:7:::


    3. Save the file



    4. Start Bash again with root privileges and set your password



       sudo bash
      passwd <your-user-name>


      You can now set a new password without having to enter the previous one.








    share|improve this answer





















    • 8





      this works but the official directory is now similar to %localappdata%PackagesCanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgscLocalStaterootfsetcshadow

      – Mauro Destro
      Dec 21 '17 at 8:13






    • 7





      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 '18 at 5:29








    • 1





      This is the winner! Worked great when the first answer did not.

      – Kim
      Mar 15 '18 at 15:29






    • 1





      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 '18 at 10:00






    • 1





      This answer worked exactly as outlined above. The first answer did not work for me.

      – Shanemeister
      Feb 20 at 15:01














    39












    39








    39







    The above did not work. Even after changing default user, Bash always opened with my user.



    So instead I did this, which worked:





    1. Edit this file (in notepad or notepad++):



      %localappdata%lxssrootfsetcshadow



    2. Find your normal user, for example:



      user1:$jsdjksadgfhsdf.saflsdf.sadf.safd:17299:0:99999:7:::


      and simply remove the hash part (below part)



      $jsdjksadgfhsdf.saflsdf.sadf.safd


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



      user1::17299:0:99999:7:::


    3. Save the file



    4. Start Bash again with root privileges and set your password



       sudo bash
      passwd <your-user-name>


      You can now set a new password without having to enter the previous one.








    share|improve this answer















    The above did not work. Even after changing default user, Bash always opened with my user.



    So instead I did this, which worked:





    1. Edit this file (in notepad or notepad++):



      %localappdata%lxssrootfsetcshadow



    2. Find your normal user, for example:



      user1:$jsdjksadgfhsdf.saflsdf.sadf.safd:17299:0:99999:7:::


      and simply remove the hash part (below part)



      $jsdjksadgfhsdf.saflsdf.sadf.safd


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



      user1::17299:0:99999:7:::


    3. Save the file



    4. Start Bash again with root privileges and set your password



       sudo bash
      passwd <your-user-name>


      You can now set a new password without having to enter the previous one.









    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Oct 11 '18 at 9:22









    Zanna

    51k13138242




    51k13138242










    answered May 13 '17 at 15:59









    Vladimir JirasekVladimir Jirasek

    49133




    49133








    • 8





      this works but the official directory is now similar to %localappdata%PackagesCanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgscLocalStaterootfsetcshadow

      – Mauro Destro
      Dec 21 '17 at 8:13






    • 7





      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 '18 at 5:29








    • 1





      This is the winner! Worked great when the first answer did not.

      – Kim
      Mar 15 '18 at 15:29






    • 1





      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 '18 at 10:00






    • 1





      This answer worked exactly as outlined above. The first answer did not work for me.

      – Shanemeister
      Feb 20 at 15:01














    • 8





      this works but the official directory is now similar to %localappdata%PackagesCanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgscLocalStaterootfsetcshadow

      – Mauro Destro
      Dec 21 '17 at 8:13






    • 7





      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 '18 at 5:29








    • 1





      This is the winner! Worked great when the first answer did not.

      – Kim
      Mar 15 '18 at 15:29






    • 1





      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 '18 at 10:00






    • 1





      This answer worked exactly as outlined above. The first answer did not work for me.

      – Shanemeister
      Feb 20 at 15:01








    8




    8





    this works but the official directory is now similar to %localappdata%PackagesCanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgscLocalStaterootfsetcshadow

    – Mauro Destro
    Dec 21 '17 at 8:13





    this works but the official directory is now similar to %localappdata%PackagesCanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgscLocalStaterootfsetcshadow

    – Mauro Destro
    Dec 21 '17 at 8:13




    7




    7





    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 '18 at 5:29







    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 '18 at 5:29






    1




    1





    This is the winner! Worked great when the first answer did not.

    – Kim
    Mar 15 '18 at 15:29





    This is the winner! Worked great when the first answer did not.

    – Kim
    Mar 15 '18 at 15:29




    1




    1





    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 '18 at 10:00





    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 '18 at 10:00




    1




    1





    This answer worked exactly as outlined above. The first answer did not work for me.

    – Shanemeister
    Feb 20 at 15:01





    This answer worked exactly as outlined above. The first answer did not work for me.

    – Shanemeister
    Feb 20 at 15:01











    25














    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:SOFTWAREMicrosoftWindowsCurrentVersionLxss).DefaultUsername
    lxrun /setdefaultuser root
    bash -c "passwd $lxssUsername"
    lxrun /setdefaultuser $lxssUsername





    share|improve this answer


























    • getting E r r o r : 0 x 8 0 0 7 0 0 0 2 in powershell

      – Nitin Sawant
      Mar 5 at 6:45
















    25














    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:SOFTWAREMicrosoftWindowsCurrentVersionLxss).DefaultUsername
    lxrun /setdefaultuser root
    bash -c "passwd $lxssUsername"
    lxrun /setdefaultuser $lxssUsername





    share|improve this answer


























    • getting E r r o r : 0 x 8 0 0 7 0 0 0 2 in powershell

      – Nitin Sawant
      Mar 5 at 6:45














    25












    25








    25







    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:SOFTWAREMicrosoftWindowsCurrentVersionLxss).DefaultUsername
    lxrun /setdefaultuser root
    bash -c "passwd $lxssUsername"
    lxrun /setdefaultuser $lxssUsername





    share|improve this answer















    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:SOFTWAREMicrosoftWindowsCurrentVersionLxss).DefaultUsername
    lxrun /setdefaultuser root
    bash -c "passwd $lxssUsername"
    lxrun /setdefaultuser $lxssUsername






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 7 '17 at 1:29









    muru

    1




    1










    answered Jun 6 '17 at 23:52









    Richard SzalayRichard Szalay

    35133




    35133













    • getting E r r o r : 0 x 8 0 0 7 0 0 0 2 in powershell

      – Nitin Sawant
      Mar 5 at 6:45



















    • getting E r r o r : 0 x 8 0 0 7 0 0 0 2 in powershell

      – Nitin Sawant
      Mar 5 at 6:45

















    getting E r r o r : 0 x 8 0 0 7 0 0 0 2 in powershell

    – Nitin Sawant
    Mar 5 at 6:45





    getting E r r o r : 0 x 8 0 0 7 0 0 0 2 in powershell

    – Nitin Sawant
    Mar 5 at 6:45











    0














    For those of you who lost the root password, what worked for me, was updating to Ubuntu 18.04 LTS via the Windows Store. Note, the windows store has two distinct options:




    1. Ubuntu

    2. Ubuntu 18.04 LTS (Pick this one)


    To check your current version, run the following as any user:



    cat /etc-*release


    You should see a line in the output that says:



    DISTRIB_RELEASE=16.01


    If you see that, then definitely update to 18.04, and it will prompt you to create new UNIX credentials.






    share|improve this answer




























      0














      For those of you who lost the root password, what worked for me, was updating to Ubuntu 18.04 LTS via the Windows Store. Note, the windows store has two distinct options:




      1. Ubuntu

      2. Ubuntu 18.04 LTS (Pick this one)


      To check your current version, run the following as any user:



      cat /etc-*release


      You should see a line in the output that says:



      DISTRIB_RELEASE=16.01


      If you see that, then definitely update to 18.04, and it will prompt you to create new UNIX credentials.






      share|improve this answer


























        0












        0








        0







        For those of you who lost the root password, what worked for me, was updating to Ubuntu 18.04 LTS via the Windows Store. Note, the windows store has two distinct options:




        1. Ubuntu

        2. Ubuntu 18.04 LTS (Pick this one)


        To check your current version, run the following as any user:



        cat /etc-*release


        You should see a line in the output that says:



        DISTRIB_RELEASE=16.01


        If you see that, then definitely update to 18.04, and it will prompt you to create new UNIX credentials.






        share|improve this answer













        For those of you who lost the root password, what worked for me, was updating to Ubuntu 18.04 LTS via the Windows Store. Note, the windows store has two distinct options:




        1. Ubuntu

        2. Ubuntu 18.04 LTS (Pick this one)


        To check your current version, run the following as any user:



        cat /etc-*release


        You should see a line in the output that says:



        DISTRIB_RELEASE=16.01


        If you see that, then definitely update to 18.04, and it will prompt you to create new UNIX credentials.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 10 mins ago









        Janac MeenaJanac Meena

        1114




        1114

















            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?



            Popular posts from this blog

            Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

            Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

            Should I use Docker or LXD?How to cache (more) data on SSD/RAM to avoid spin up?Unable to get Windows File...