This blog post explains the steps needed to reset the
sudo password for the
Ubuntu 20.04 LTS version
in the WLS (Windows for Linux SubSystem) - Windows 10.
WLS Vs Typical Linux Distros
Once you configure Ubuntu LTS in the WLS, it does not ask for the password whenever you invoke the App in the Windows OS. As the Windows for Linux SubSystem, it automatically saves the username and password credentials in the cache. With which it automatically picks up the user and logs him/her in whenever you invoke the App. It is unlike the typical Ubuntu OS (or any other linux distro), where you would be asked for the password whenever you login.
Post logging in, if you had to do with any of the administrative commands, you may need to prefix it with
sudo which will ask for the password once to ensure that you are the authenticated user and you are indeed clear on what you do. If you have forgotten the login password, you can’t succeed in getting into the
Resolution - Easy way
A simple way to resolve the issue is to reset the password via
- Open the Command Prompt
- Type the command
ubuntu config --default-user rootto reset the user to login as root in the linux distro
- Invoke the Linux distro -
- You would be logged in with the root user now - as per the config we made in step #2.
- Verify the current user with the command
whoami- to be very sure of it.
- Change the password for the user of your choice by giving
- Enter the password of your choice to the user you wish to login.
- Enter the password again for confirmation.
- Exit the Linux distro by pressing
- Again, set the default user as
ubuntu config --default-user <user>.
- Enter the Ubuntu exe for the distro in the same terminal -
- You would be logged in with your
usernow on the linux distro.
- Verify the password by issuing any command prefixed with
- Enter the password you just created.
- A successful output confirms that your password reset is successful :)
Rememmber: You may need to replace the executable file with the right file name, in my case it is Ubuntu2004.exe instead of just ubuntu as that is how I have named it while installing it in my System.
Troubleshooting - How to find out the Linux distro exe file name?
You can run the distro first, and then to go the
Task Manager, drill down to the
Ubuntu 20.04 LTS app, right click on the correct executable file (.exe) and click on
Properties to get to see the file name.
Ubuntu2004.exeis located in
The following are the sequence of command output in the Windows Command Prompt.
Attempting to get the
ubuntu but it was unsuccessful
Microsoft Windows [Version 10.0.19042.985] (c) Microsoft Corporation. All rights reserved. C:\Users\Raghavan Muthu>ubuntu 'ubuntu' is not recognized as an internal or external command, operable program or batch file. C:\Users\Raghavan Muthu>ubuntu config --default-user root 'ubuntu' is not recognized as an internal or external command, operable program or batch file.
Attempt to invoke the
ubuntu executable with the correct exe file name
C:\Users\Raghavan Muthu>ubuntu2004 raghs@Raghs-LegionY540-TPIN:~$ exit logout
Back to Windows Command Prompt, reset the default user to
C:\Users\Raghavan Muthu>ubuntu2004 config --default-user root C:\Users\Raghavan Muthu>
Invoke the Linux Distro, and verify the User
C:\Users\Raghavan Muthu>ubuntu2004 Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 4.4.0-19041-Microsoft x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Wed Jun 9 22:29:13 IST 2021 System load: 0.52 Usage of /home: unknown Memory usage: 85% Swap usage: 1% Processes: 9 Users logged in: 0 IPv4 address for eth2: 192.168.85.1 IPv4 address for eth3: 192.168.244.1 IPv4 address for wifi0: 192.168.1.11 IPv6 address for wifi0: 2401:4900:1f2a:39c2:1df7:1e21:2f36:49bd IPv6 address for wifi0: 2401:4900:1f2a:39c2:b916:7d3f:44e9:144 69 updates can be installed immediately. 18 of these updates are security updates. To see these additional updates run: apt list --upgradable The list of available updates is more than a week old. To check for new updates run: sudo apt update This message is shown once once a day. To disable it please create the /root/.hushlogin file. root@Raghs-LegionY540-TPIN:~#
Verify the current user
root@Raghs-LegionY540-TPIN:~# whoami root
Reset the password to the user of your choice
root@Raghs-LegionY540-TPIN:~# passwd raghs New password: Retype new password: passwd: password updated successfully
Exit and come back to Windows Command Prompt
root@Raghs-LegionY540-TPIN:~# exit logout C:\Users\Raghavan Muthu>
Reset the default user back to the user of your choice to the linux distro
C:\Users\Raghavan Muthu>ubuntu2004 config --default-user raghs C:\Users\Raghavan Muthu>
Invoke the linux distro now to see it logs in with the right user of your choice
C:\Users\Raghavan Muthu>ubuntu2004 raghs@Raghs-LegionY540-TPIN:~$
Verify the password change with any command prefixed with
raghs@Raghs-LegionY540-TPIN:~$ sudo ls [sudo] password for raghs: prfsnl study userCreds.txt raghs@Raghs-LegionY540-TPIN:~$
Resolution - Alternate way
You can go to the Ubuntu 20.04 LTS App in the Windows Programs, uninstall it and reinstall it from the Windows Store.
Please note that you may lose the data if any, you had it in the Linux distro. Be mindful of the fact.
Raghavan alias Saravanan Muthu
09 Jun 2021 | Wed | 22 56 PM IST