How to set new user password in Ubuntu WSL 22.04?

Open terminal using ‘cmd.exe’

run the wsl with root user

type passwd <username> to modify the user password

Once done type ‘exit’ to exit wsl.

Now use wsl and check any command with sudo.

C:\Users\yodas>wsl -u root
root@localhost:/mnt/c/Users/yogi# passwd yogi
New password:
Retype new password:
passwd: password updated successfully
root@localhost:/mnt/c/Users/yodas# exit
logout

Source: Unable to change the root password in Windows 10 WSL – Ask Ubuntu

About the Author

Yogi

24 years of experience in various layers of software. Primarily experienced in system side software design and development on server management software. Interested in linux development in x86 and arm architecture.