In a Linux system, in case you forgot your password, you can reset it by booting into GRUB and resetting it from there. However, WSL doesn’t follow a normal boot process, which makes the aforementioned process null and void. However, if you want to reset the password using WSL, there is an easier way to do so.
This guide will discuss the process of changing user passwords in Ubuntu WSL. The process for changing the password on other WSL distributions is more or less the same.
Change the User Password in Ubuntu WSL
Change the default username for your WSL distro to root. Then, run the config command as follows: ubuntu config –default-user root Launch your Linux distribution, in case you are working with a default WSL distro. Reset your password by typing in the passwd command. passwd To reset the password of a specific user, pass the username with the command. For example: passwd winibhalla Leave your WSL session and set the default user of the WSL distro back to your user account. ubuntu config –default-user winibhalla
Note: You can use the following commands to change your default user to root in a WSL distro.
Replace root with another user account name, so that the system sets it as the default user account for the distro in use. The commands to set the default user to root are the same in other Linux distributions as well.
To set root as the default user on Ubuntu:
On OpenSuse Linux:
Changing the default user on Kali Linux is easy as well:
To change the default user to root on Debian:
Resetting Your Password on WSL, the Easy Way
The process is rather simple, and even a novice can do it by using the above steps. The idea is to just follow the process step by step, and you just can’t go wrong.
On a traditional Linux installation, you can use the passwd command to change your account password easily. Unix is similar to Linux in terms of its architecture and commands, and the steps to change the user password are the same as in Linux.