4

I forgot the password for the Ubuntu bash on windows. I tried to reset it by following the instructions https://www.top-password.com/blog/forgot-linux-bash-password-in-windows-10/ but the windows cmd threw the following:

'ubuntu' is not recognized as an internal or external command, operable program or batch file.

I tried with both, ubuntu and ubuntu1806/04. I also tried passwd root but it says "you may not view or modify password".

I have tried wsl -u root but it says wsl is not installed. If I try to install it, I need to input the password.

I also tried to uninstall the ubuntu bash, when I click uninstall on the task bar, it redirects me to the control panel option for uninstalling programs, but it is not shown on the list to uninstall it. How can I reset the password?

jokerdino
  • 41,320
Lis Lou
  • 49
  • 3
  • Since you're getting ubuntu isn't a recognized command, please verify the Ubuntu app you're using. If it's Ubuntu, command will be ubuntu but for 18.04, it'll be ubuntu1804 and for 16.04, it'll be ubuntu1604. Moreover, control panel only shows program which were installed using executables instead of Windows Store, i.e. it shows programs with executables not UWP – Kulfy Apr 10 '20 at 11:36
  • yes, I tried with both, ubuntu and ubuntu1806/04. I also tried passwd root but it says "you may not view or modifz password" I have tried wsl -u root but it says wsl it's not install. If I try to install it I need to input the password – Lis Lou Apr 10 '20 at 12:28
  • Which version of Windows are you using? Do you receive insiders updates? – Kulfy Apr 10 '20 at 13:42
  • windows 10 home 64 bit. Normally it updates regularly – Lis Lou Apr 10 '20 at 14:08
  • Open Powershell as admin and run Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux and then reboot the system. Try wsl -l -v. – Kulfy Apr 11 '20 at 10:06

2 Answers2

7

if you forgot password for your own account then try to login with root user and reset it for your account (instruction mentioned below).

# passwd <your_user>

if you forgot password for the root account; try to open a root shell with sudo -i and type your own user's password and change the password for the root account.

# passwd root

Another options is resetting from Windows Powershell for newer Windows10 version:

  1. Open PowerShell and enter the root of your default WSL distribution using the command:

    wsl -u root
    
  2. If you need to update the forgotten password on a distribution that is not your default, use the command: wsl -d Debian -u root, replacing Debian with the name of your targeted distribution.

  3. Once your WSL distribution has been opened at the root level inside PowerShell, you can use this command to update your password: passwd

  4. You will be prompted to enter a new UNIX password and then confirm that password. Once you're told that the password has updated successfully, close WSL inside of PowerShell using the command: exit


this is for previous versions:

For Creators Update version of Windows and earlier

If you're running Windows 10 Creators update or earlier, you can change the default Bash user by running the following commands:

  1. Change the default user to root:

    C:\> lxrun /setdefaultuser root
    
  2. Run bash.exe to now login as root:

    C:\> bash.exe
    
  3. Reset your password using the distribution's password command, and close the Linux Console:

    # passwd username
    # exit
    
  4. From Windows CMD, reset your default user back to your normal Linux user account:

    C:\> lxrun.exe /setdefaultuser username
    

For Fall Creators Update and later

To see what commands are available for a particular distribution, run [distro.exe] /? (replace distro with the distribution name you have installed like ubuntu.exe /?).

Step by step instructions using Ubuntu:

  1. Open CMD
  2. Set the default Linux user to root:

    C:\> ubuntu config --default-user root
    
  3. Launch your Linux distribution (ubuntu). You will automatically login as root.
  4. Reset your password using the passwd command:

    # passwd username
    
  5. From Windows CMD, reset your default user back to your normal Linux user account.

    C:\> ubuntu config --default-user username
    

Note: Replace ubuntu with ubuntu1604 or ubuntu1804 if you're using Ubuntu 16.04 or Ubuntu 18.04 app.

αғsнιη
  • 35,660
-1

To change Password of ubuntu bash user here is step

open windows power shell type below command in shell

PS C:\Users\user.name> wsl -u root

here we access root user of wsl if you have any other use then write below command ( for example )

PS C:\Users\user.name> wsl -u [username]

it will show like this

username:/mnt/c/Users/user.name$

then write below command

passwd [username]

this will show like

New password:

now write new password and retype new password and hit Enter now restart lxssManager service