How to Set Default User for Windows Subsystem for Linux (WSL) Distro in Windows 10


The Windows Subsystem for Linux (WSL) is a new Windows 10 feature that enables you to run native Linux command-line tools directly on Windows, alongside your traditional Windows desktop and modern store apps.

When you have Windows Subsystem for Linux (WSL) enabled, you can install WSL distro apps from the Microsoft Store, and export and import WSL distros.

The first time a newly installed WSL distro runs, a Console window will open, and you'll be asked to wait for a minute or two for the installation to complete.

Once installation is complete, you will be prompted to create a new user account (and its password).

Creating your Linux user is the first step in setting up a new Linux distribution on WSL. The first user account you create is automatically configured with a few special attributes:
  1. It is your default user -- it signs-in automatically on launch.
  2. It is Linux administrator (a member of the sudo group) by default.

Each Linux distribution running on the Windows Subsystem for Linux has its own Linux user accounts and passwords. You will have to configure a Linux user account any time you add a distribution, reinstall, or reset. Linux user accounts are not only independent per distribution, they are also independent from your Windows 10 user account.

The default user for a WSL distro is the user that is automatically signed in by default when you run the WSL distro.

You can set the default user for a WSL distro to root (aka: built-in Administrator) or any available user for that WSL distro.

See also: Linux User Account and Permissions | Microsoft Docs

This tutorial will show you how to set a default user for a Windows Subsystem for Linux (WSL) distro in Windows 10.


 CONTENTS:

  • Option One: Set Default User to Root for a WSL Distro
  • Option Two: Set Default User to Specified User for a WSL Distro


EXAMPLE: Ubuntu distro with user "brink" set as the default user
Name:  default_user_in_WSL_distro.png
Views: 200
Size:  3.8 KB






Set Default User for Windows Subsystem for Linux Distro in Windows 10 OPTION ONE Set Default User for Windows Subsystem for Linux Distro in Windows 10
Set Default User to Root for a WSL Distro

1. Open a command prompt or PowerShell.

2. Copy and paste the command below into the command prompt or PowerShell for the .exe file of the WSL distro name (ex: "Ubuntu") you want to set the default user for, and press Enter. (see screenshot below)

(Ubuntu)
ubuntu config --default-user root

OR

(Ubuntu 18.04 LTS)
ubuntu1804 config --default-user root

OR

(Ubuntu 16.04 LTS)
ubuntu1604 config --default-user root

OR

(openSUSE Leap 42)
openSUSE-42 config --default-user root

OR

(SUSE Linux)
SLES-12 config --default-user root

OR

(Debian)
debian config --default-user root

OR

(Kali Linux)
kali config --default-user root

Name:  Set_default_user_as_root_for_WSL_distro.png
Views: 188
Size:  4.2 KB






Set Default User for Windows Subsystem for Linux Distro in Windows 10 OPTION TWO Set Default User for Windows Subsystem for Linux Distro in Windows 10
Set Default User to Specified User for a WSL Distro

1. Open a command prompt or PowerShell.

2. Type the command below into the command prompt or PowerShell for the .exe file of the WSL distro name (ex: "Ubuntu") you want to set the default user for, and press Enter. (see screenshot below)

(Ubuntu)
ubuntu config --default-user <username>

OR

(Ubuntu 18.04 LTS)
ubuntu1804 config --default-user <username>

OR

(Ubuntu 16.04 LTS)
ubuntu1604 config --default-user <username>

OR

(openSUSE Leap 42)
openSUSE-42 config --default-user <username>

OR

(SUSE Linux)
SLES-12 config --default-user <username>

OR

(Debian)
debian config --default-user <username>

OR

(Kali Linux)
kali config --default-user <username>

Substitute <username> in the command above with the actual UNIX user (ex: "brink") you want to be the default user for this WSL distro.

For example: ubuntu config --default-user brink

Name:  Set_default_user_for_WSL_distro.png
Views: 188
Size:  4.4 KB


That's it,
Shawn


Related Tutorials