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:

1# passwd
2# passwd pinkepank

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

Translations: