Set Default User for WSL in Windows 10

Starting with Windows 10 Fall Creators Update, you can have different Linux distros installed inside of Windows Subsystem for Linux (WSL). Once you enable the feature, you can go to the Store and install any available Linux distro you want from there. If you wish to change the default user for the distro that you have installed, here's how to set it for WSL in Windows 10.


In Windows 10 Fall Creators Update, Windows Subsystem for Linux is finally out of beta. Not only can you install and run multiple Linux distros, but also for your convenience, they are available right in the Microsoft Store (formerly known as the Windows Store). As of this writing, you can install openSUSE Leap, SUSE Linux Enterprise, and Ubuntu.

The default UNIX user is the user account that appears signed in when you open the appropriate Linux console. By default, it opens with the user name that you've specified during the initial setup of the feature.

Default User Wsl

If you've added a new user to the distro you are using, you might want to make it the default UNIX user for WSL. I am going to make the user bob default instead of the winaero account.

Here is how it can be done.

To set the default user for WSL in Windows 10, do the following.

  1. Open a new command prompt instance.
  2. To set the default UNIX user for Ubuntu in WSL, run the command:
    ubuntu config --default-user new_user_name

    Substitute the new_user_name portion with the actual user name. In my case, it is bob.Windows 10 Set Default User Wsl

  3. If you are using openSUSE, run the following command:
    opensuse-42 config --default-user new_user_name
  4. If you are using SUSE Linux Enterprise Server, run the following command:
    sles-12 config --default-user new_user_name

From now, the specified user account will be used as your default UNIX user for WSL. The Linux console will open with this user.Windows 10 New Default User

Tip: The binary file name of each distro can be found with Task Manager. Open the Windows Task Manager and expand the running Linux console row on the Processes tab. See the following screenshot.

Windows 10 Wsl Binary Names

At the moment of this writing, Microsoft is using the following names:

  • Ubuntu - ubuntu.exe
  • openSUSE Leap 42 - opensuse-42.exe
  • SUSE Linux Enterprise Server - sles-12.exe

Note: In older releases of Windows 10, which support only Bash On Ubuntu, you should use the following command:

lxrun.exe /setdefaultuser username

That's it.

1 thought on “Set Default User for WSL in Windows 10

  1. Karl Ruetz

    The command “openSUSE-42 config –default-user root” does not work.


    > openSUSE-42 config –default-user root
    Default UNIX user set to: root

    Yet the user is still the original user when I start openSuse.

    Also, I told WSL to use the same password for root as the user.
    I cannot sudo. I cannot su. Basically, my installation is useless.
    Any ideas?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *