How to reset Ubuntu 20.04 password in WSL
If you don't remember the password used in your WSL Linux distro (default user) to sudo in the terminal, this article will surely help you, so follow the steps below to add a new password.
What's WSL?
Windows Subsystem for Linux (WSL) lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual-boot setup. for more information please head over to here.
Default User: by opening the WSL distro terminal for the first time, you will see a progress bar, and immediately you will be prompted to type a new username and enter a password. this user account is added to "sudor" group will be used every time you try to use this WSL distro and you will be signed in by default.
Note: each WSL distro has its own user credentials which are even separate from the windows account.
Step one: Changing default user to root.
When you open the WSL terminal anything that comes before "@" is the default user and must be changed to the root user, and for doing so, open a cmd as administrator and type the below command:
ubuntu2004 config --default-user root

Step two: Resetting default user password.
If you open the WSL terminal again, you will see "root" before "@" sign and now you can change the default user's password by typing:
passwd [username]

Step three: setting back the default user.
After setting the new password now we can set the default user from root to the prev user.
ubuntu2004 config --default-user [username]

The below command only differs among the WSL distros.
- Ubuntu: ubuntu config --default-user root
- OpenSUSE Leap 42: openSUSE-42 config --default-user root
- SUSE Linux: SLES-12 config --default-user root
- Debian: debian config --default-user root
- Kali Linux: kali config --default-user root
Follow me for More Mahdi Akbary
Twitter @Mahdi_Akbary
更多推荐




所有评论(0)