Trying to use sudo in WSL but my Microsoft account (which I'm logged into as Admin on Windows 10) password won't work. How can I fix it?

When I look into what my admin password is on Windows 10, everything seems to point to it being linked to the Microsoft account I have connected.

I validated this, it seems to be the case that I am not currently using a local account:

enter image description here

But the same password I'm able to use to log into this Microsoft account with does not work when I attempt to run sudo in WSL. There is only one account on my PC.

What detail have I missed or how can I troubleshoot?


Solution 1:

Your Windows Subsystem for Linux (WSL) password is not your Windows password. To change your WSL password, try the following steps.

On a Windows prompt, enter the command:

wsl --user root

You should be logged in as root into your WSL. Now, use the passwd command to change the password for your user:

passwd username

Replace username with your actual Linux username.

You will be asked to type a new password without being asked for the current one. Once you're done, just leave the session with exit. Your user's password should have been changed.

Source: How To Reset Your Forgotten Linux Password in WSL (CloudSavvyIT)