I have installed Kali Linux subsystem on windows. And now I have forgotten the root password in Kali, there is just the terminal of Kali Linux and nothing else. How can I reset my password safely?
Note: I have installed both Ubuntu and Kali Linux installed at the same time
But when I run bash by default it opens up ubuntu
Best Answer
In new Windows versions, users can install and run multiple GNU/Linux distributions. One can configure the default distribution (i.e. the distribution that comes up with
wsl.exe
) withwslconfig /s <disrto_name>
command. e.g. To open Kali withwsl.exe
at first run, use this commandwslconfig /s kali-linux
or runkali.exe
.First of all, I don't know if this procedure is safe or not. At the time of writing, WSL manages the default login user from
DefaultUID
registry (this may change in future). Close any opened WSL instance. To edit this registry value, open Registry Editor orregedit.exe
from start menu or run dialog box. Go to this registry path or type this path with Ctrl + L in that Window:You may see one or multiple subkeys (like subfolders) with names something like
{12345678-1234-1234-1234-123456789012}
(called GUID). Double click on them to open one-by-one and match theDistributionName
value with your desired distribution name, here it will bekali-linux
(see below). Double click on theDefaultUID
value and change it to ZERO. Zero is for root user and1000
or0x3e8
(in hexadecimal) for normal users.Open
wsl.exe
in command prompt. The prompt changes from$
to#
(means root user). Runpasswd
command in Kali, change root password as usual. Now go back to previous registry key, change Zero to previous value (or3e8
in hex). Here is an example of the registry values:Further details:
passwd
manual page