How to reset WSL user password
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
- 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
May be interested
- How to use Password Reset Disk to reset Windows password?in previous articles, network administrator showed you how to create a password reset disk on windows 7/8/10. in the following article, network administrator will guide you how to use password reset disk to reset windows password.
- How to Reset SA Password in Sql Serverthis wikihow teaches you how to reset a forgotten system administrator (sa) password in microsoft's sql server. you can do this by logging in with windows authentication, using command prompt, or using single-user mode. understand how this...
- How to Reset a Lost Admin Password on Mac OS Xif you're logged into your mac with your apple id account, you may be able to use it to reset your admin password. if you aren't you can use recovery mode on your mac to open the reset password utility. you can also reset a password with...
- How to retrieve a Tik Tok password when it is losttik tok password can be retrieved via email or via phone number registered tik tok account, when users forget or lose the password tik tok.
- Top 5 easiest ways to reset Windows 10 computer passwordknowing simple and effective ways to reset your computer password will help you easily escape the nightmare of resetting your laptop when you forget your password.
- Create Windows Password Reset Disk on Windows 7 with USB Flash Drivein the following article, the network administrator will guide you through the basic steps to create a password recovery tool - windows password reset disk with a usb drive on windows 7 operating system in case if you forget the login password. enter, you can still access your computer and create a new password.
- Ways to reset BIOS password or remove BIOS passwordclear the bios password, set the bios to default mode in case you forget the bios password, buy an old device without knowing the bios password, here are ways you can use it.
- How to Reset Router Passwordafter resetting your router password, you will be able to log in and make the necessary changes or customizations. the only way to reset the router password is to restore factory settings by pressing the reset button right on the device.
- 3 ways to reset lost Mac passwordforgetting your mac's admin password means you will no longer have access to your mac. but there's no need to worry because it's possible to reset your mac's password and regain access by entering some other details.
- Instructions to reset Netflix account passwordwhen users forget their netflix account password, you need to reset the netflix account password to retrieve the password, then proceed to change the netflix password as you like.