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 the WSL user password.

Use root account khoản

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.

Instead of, replace username with the user account name and distroname with your WSL distribution. For example, the executable file openSUSE 15.3 Leap will 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 menu Start, Command Prompt or choose it from Windows Terminal.

See more:  Instructions on how to use System Restore on Windows
Launch the distro using the Start menu, Command Prompt or Windows Terminal
Launch the distro using the Start menu, Command Prompt or Windows Terminal

After launching, you should log in as root.

Finally, use the command passwd 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 command config 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.

Source link: How to reset WSL user password
– https://techtipsnreview.com/

, , ,

Leave a Reply

Your email address will not be published. Required fields are marked *