How to reset Ubuntu login Microsoft WSL

Published on Author JFLeave a comment

Windows Subsystem for Linux has started to make Windows into an actual development platform! It’s not there yet, but it is getting there. Although I really appreciate how *nix and Macs have created the majority of dev workflows, I am excited to be able to use an upgradable $500 Windows 10 laptop instead of a $1,500 MacBook Pro with a really awful keyboard.

While we’re on the way to a great cross-platform solution, you might be only using WSL infrequently and have forgotten the password. Note that in Ubuntu world you always sudo for root access. As a best practice for all *nix machines you should never login as root.

What you’re going to do is change the default user to root, update the password using root privileges, then return your previous user to default.

It’s so easy, but it depends on which update you are using! See the bottom of the page for alternatives.

I’m on the Fall Creator’s Update with Ubuntu installed. The username example is “processio”

Open Windows CMD
Set the default Linux user to root:

C:\>ubuntu config --default-user root

Launch your Linux distribution (ubuntu). You will automatically login as root:

root@machine-name:~#

Reset your password using the passwd command (do the command then enter the password when prompted):

passwd processio

Close the WSL window.

Go back to CMD, reset your default user back to your normal Linux user account.

C:\> ubuntu config --default-user processio

Open WSL and you’re done! Make sure to try sudo apt-get update to confirm your password is working:

processio@machine-name:~#sudo apt-get update

Here’s the best reference from Microsoft:

https://docs.microsoft.com/en-us/windows/wsl/user-support

 

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.