The Computer Oracle

How to sign into "root" account by default on Windows Subsystem for Linux Bash terminal

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Track title: CC I Beethoven Sonata No 31 in A Flat M

--

Chapters
00:00 Question
00:54 Accepted answer (Score 18)
02:06 Answer 2 (Score 18)
02:26 Answer 3 (Score 3)
03:33 Answer 4 (Score 3)
03:53 Thank you

--

Full question
https://superuser.com/questions/1107986/...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#bash #ubuntu1404 #windowssubsystemforlinux #windows10v1607

#avk47



ANSWER 1

Score 18


In a command prompt with elevated permissions run the command lxrun /setdefaultuser root

lxrun is the tool for performing administrative operations on the LX subsystem.




ACCEPTED ANSWER

Score 18


The command to set the default Linux user is different in different versions of Windows.

For versions of WSL up to the Fall Creators Update, run the following command in an elevated Windows command prompt:

lxrun /setdefaultuser root

For installations after the Fall Creators Update, the command is:

<distro> config --default-user root

Substitute the distro's exe name for <distro> in the command above. So, if you're running Ubuntu, the command would be:

ubuntu config --default-user root

For openSUSE...

opensuse-42 config --default-user root

And, for SUSE Linux Enterprise Server, the command is...

sles-12 config --default-user root

Again, all of these commands are performed from an elevated Windows command prompt.

Note:
The examples above are for the root user. You may specify any other existing username in place of root.




ANSWER 3

Score 3


Use

ubuntu1604 config --default-user root & ubuntu1604.exe

I tried the solutions mentioned above but somehow I always end up with the user login rather than root




ANSWER 4

Score 3


Try my way if someone still needed.

My computer

  • Windows 10 winver: 21H1(19043).
  • Subsystem: Ubuntu 18.04 LTS.

Open Registry Editor with shortcut key: windows + r.

type: regedit and enter.

Go to this path: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss

and find the "DistributionName" you are using. (Ubuntu-18.04 is mine) Modify this name "DefaultUid" set value equal 0 then click Ok button to save. then log off and log in to reset Registry.

Open your bash shell and enjoy it.

0 is the root user's id, you can check by running this command cat /etc/passwd; and find root user.