When you first install the Ubuntu Bash shell on Windows 10, you’ll be asked to create a username and password for the Bash environment. Bash will automatically sign into that user account whenever you launch the shell, but you can change it–and its password.
You can’t just do this with standard Linux commands, however. Instead, you have to use the
lxrun command from outside the Bash environment to control this.
How User Accounts Work in Windows 10’s Bash Shell
When you set up Bash on Windows 10 by running the bash.exe program or
lxrun /install command, Windows will ask you to create a user account for use in the Bash shell. Windows calls this your “UNIX user account”. So, if you provide the name “bob” and the password “letmein”, your Linux user account will be named “bob” and will have the home folder “/home/bob”. When you need to enter your password in the shell, you’ll have to enter “letmein”. This is entirely independent from your Windows user account and password.
Every Windows user has its own Bash environment, including separate files, installed programs, and configuration settings. If another Windows user account on your computer sets up Bash, they’ll be asked to set up their own user account for the Bash environment. The Bash environments will remain entirely separate, each with their own user accounts that aren’t accessible from the other environment.
In other words, each Windows user account has its own separate Ubuntu Bash sandbox to play in.
How to Change Your Default User Account for Bash
To change your default user account in the Ubuntu Bash shell, open a Command Prompt window or PowerShell window. Right-click the “Start” button or press Windows+X on your keyboard and select “Command Prompt” to open one.
In the Command Prompt window (not a Bash shell window), run the following command. Replace “myusername” in the below command with your new username:
lxrun /setdefaultuser myusername
If the user account doesn’t already exist in the Bash environment, it will be created and you’ll be prompted for your password.
If you’d like to use the root account as your default user account, you can run the below command:
lxrun /setdefaultuser root
This will set the root user account as your default user account without a password. The root account will also be set as your default user account without a password if you installed the Bash environment with the “lxrun /install /y” command.
How to Change Your Bash User Account’s Password
To change your Bash user account’s password, you’ll need to use normal Linux commands inside the Ubuntu Bash environment. To change your password, you’d launch a Bash shell and run the following command:
You’ll be asked to enter your user account’s current password and then you’ll be asked to provide a new one.
How to Switch Between User Accounts
lxrun /setdefaultuser command controls which user account the Bash shell uses by default. However, if you’d like to use multiple user accounts with Bash, you can switch between them while inside a Bash shell.
To do this, run the following command in a Bash shell, replacing “username” with the username you want to use:
You’ll be prompted to enter the other user account’s password, and then you’ll switch to that user account in the Bash shell.
How to Create a New User Account in Bash
You can create user accounts by using the
lxrun /setdefaultuser command. However, you can also create new user accounts from within the Bash environment. To do this, just run the following command, replacing “mynewuser” with the name of your new user account.
sudo adduser mynewuser
You’ll be asked to provide your current user account’s password to authenticate, and then enter a password for the user account. You’ll also be asked to provide other information, like a “full name” and phone numbers for this account. This is all stored locally on your computer, and isn’t important. You can just press Enter to leave these fields blank.
After you create a new user account, you can switch to it using the above