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

8

6

Windows 10's Anniversary Update just came out and I immediately installed the Windows Subsystem for Linux to see how it fares. I found only one major shortcoming so far: there was no obvious way to use the root account as the default.

I know it goes against a lot of best practices and what not, but I personally don't like having to remember to type sudo in front of most commands. This can get especially annoying when I open a text file for editing with nano only to discover I have to abandon my changes because I didn't use sudo.

Is there any way to make the terminal start as root by default?

SeinopSys

Posted 2016-08-02T20:40:52.433

Reputation: 800

Answers

7

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.

Fred Lackey

Posted 2016-08-02T20:40:52.433

Reputation: 237

3For the newer Ubuntu 18.04 distro, the command is:

ubuntu1804 config --default-user root – NetRay – 2018-08-06T15:37:49.223

Where can I see if I use the WSL fall creater update? – Timo – 2019-10-23T18:11:41.620

lxrun does not work in my powershell. I use Wsl Debian, do you know the command for this to start the app as root? – Timo – 2019-10-23T18:12:32.370

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.

Jacob Larsen

Posted 2016-08-02T20:40:52.433

Reputation: 181

1Just to clarify: the lxrun command should be executed in a Windows command prompt. This solution works great. – Adrian Keister – 2017-07-25T14:09:22.520

3The lxrun.exe command is no longer supported. – Fred Lackey – 2018-02-02T16:46:34.200