Linux OSBN/Ubuntuusers Planet Windows XING / LinkedIn / Amazon

Short tip: Forgot WSL root password

If you forget the root password (or a user password) of your WSL installation (Windows Subsystem for Linux), using the registry might help you. Because WSL is rather a lightweight kernel expansion than a full-featured VM, the typical live-CD trick (mounting the filesystem and running chroot) won’t help.

Below the path KEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss you will find additional keys per WSL installation. Here you will also find additional keys – using DefaultUid the start user can be changed. Usually, WSL starts with a unprivileged user (UID 1000) – and this user can’t change the root password or its own password if the old one is not known. Double-click on the item and set the value to 0 temporarily – WSL must not be started during this.

Windows registry with Debian WSL settings

Afterwards double-clicking the appropriate WSL icon will start a root shell. Using this, you can now reset the passwords:

# passwd
# passwd pinkepank

Finally, it is a good idea to undo the change.

Sharing is caring

2 Comments Add New Comment

  1. Someone who got here by search results says:

    It can be done easier:
    1. Start powershell or cmd.exe
    2. wsl -u root
    3. passwd

  2. jos says:

    Thanks to the commenter with the solution below because the solution in this article wasn’t working for me.
    1. Start powershell or cmd.exe
    2. wsl -u root
    3. passwd

Leave a Reply

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