How to reset WSL user password
Windows Subsystem for Linux, commonly known as WSL, is a feature that allows users to run supported Linux distributions in Windows. Unlike dual boot, WSL runs inside Windows like a regular Windows application.
On WSL, password forgetting is handled differently than in a normal Linux environment, as there is no editable bootloader. It also doesn't have an init system that you can hijack to launch a root shell. This guide will show you the steps to reset WSL user password.
Use root account
A simple way to recover or reset forgotten passwords for WSL users is to use the root account. In most WSL distributions, the root account is enabled and no password is required.
Since WSL automatically logs in to the default account set without a password prompt, you can change the configuration file and set the default account as the root account.
To change the configuration, it is necessary to use the WSL version executable. By default, the executable is located in
C:usersusernameappdataLocalMicrosoftWindowsApps.
Replace username with your user account name and distroname with your WSL distribution. For example, the openSUSE 15.3 Leap executable would be
C:UsersmteAppDataLocalMicrosoftWindowsAppsopenSUSE-Leap-15.3.exe.
To change the configuration for the distribution, launch the Command Prompt and enter the command that matches the name of your distribution. For example, for openSUSE, set the default user to root with the command:
opensuse-leap-15.3 config --default-user root
The above command will change the default user to root for the WSL openSUSE instance.
For other distributions, the command would be:
Ubuntu
ubuntu config --default-user root
Ubuntu 18.04
ubuntu18004 config --default-user root
Ubuntu 20.04
ubuntu2004 config --default-user root
Kali Linux
kali config --default-user root
Debian
debian config --default-user root
Arch Linux
arch config --default-user root
The final step is to login to the distribution and change the password for the target username. You can launch your distro using the Start menu, Command Prompt, or selecting it from the Windows Terminal.
After launching, you should log in as root.
Finally, use the passwd command to change the password. For example, to change the password for username cap, set the command as:
passwd cap
Restore default user
After you reset the password for a specific user, it is best to change the default user instead of using the root account.
To do that, use the config command and replace username with the desired account. Eg:
opensuse-leap-15.3 config --default-user cap
Remember to replace it with your distribution's name.
Hope you are succesful.
You should read it
- How to Reset a Windows 7 Password
- How to reset the password for sudo in Debian
- Fix some errors when using Password Reset Wizard
- How to Reset Admin Password on Mac OS X
- How to reset Admin password on Windows with Sticky Keys
- 7 free Windows password recovery tools
- How to retrieve a Tik Tok password when it is lost
- How to Use a Password Reset Disk (Windows)
- How to fix the error of creating Password Reset Disk on Windows
- How to Reset a Forgotten Password on Windows
- How to use Password Reset Disk to reset Windows password?
- How to Reset a Lost Admin Password on Mac OS X
Maybe you are interested
How did 'LoveBug' change the world of malware? 14 great features on Google you may not know yet The art of creating great paintings from letters How to preserve banh chung and banh Tet is long How to become a good UX Designer without a degree! 50 soft skills needed to be happy and successful for life (Part 2)