Quick Links

When you first install Ubuntu or another Linux distribution on Windows 10, you're asked to create a UNIX username and password. Bash automatically signs into that user account when you launch the shell, but you can change those credentials if you need to.

How User Accounts Work in the Linux Environment

Related: How to Install and Use the Linux Bash Shell on Windows 10

When you set up a new Linux distribution by launching it after installing it, you're be asked to create a user account for 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 is named "bob" and has the home folder "/home/bob." When you need to enter your password in the shell, you have to enter "letmein." These credentials are entirely independent from your Windows user account and password.

Every Linux environment you install has its own configuration, including separate files, installed programs, and configuration settings. You'll have to create a UNIX username and password for every Linux distribution you install.

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.

To open a Command Prompt window, open the Start menu, search for "cmd", and then press Enter. To open a PowerShell window, right-click the Start button (or press Windows+X), and then select "Windows PowerShell" from the Power User menu.

In the Command Prompt or PowerShell window (not a Bash shell window), run the appropriate command for your Linux distro. Replace "username" in the below command with your new username:

  • Ubuntu: ubuntu config --default-user username
  • openSUSE Leap 42:
            opensuse-42 --default-user username
        
  • SUSE Linux Enterprise Server 12:
            sles-12 --default-user username
        

You can only specify a user account that already exists in the Linux environment.

For example, to set the default user as root, run the following command. This is convenient if you've forgotten your UNIX user account password, as the root user has full system access. You'll be able to create new user accounts and reset your existing user account's password from the root shell.

  • Ubuntu:
            ubuntu config --default-user root
        
  • openSUSE Leap 42:
            opensuse-42 --default-user root
        
  • SUSE Linux Enterprise Server 12:
            sles-12 --default-user root
        

How to Create a New User Account in Bash

You can create user accounts by running the

        adduser
    

command from within the Linux environment's Bash shell. For example, to do this on Ubuntu, just run the following command, replacing "newuser" with the name of your new user account:

sudo adduser newuser

Provide your current user account's password to authenticate, and then enter a password for the new user account. (If you don't remember your current UNIX account's password, use the commands we covered in the previous section to set the root user as the default user account first.)

You'll also be asked to provide other information, like a "full name" and phone numbers for the new account. This data is all stored locally on your computer, and it isn't important. You can just press Enter to leave these fields blank.

After you create a new user account, you can make it the default user account using the above command, or switch to it using the su command shown in the image below.

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 Bash environment. To change the current user account's password, you'd launch a Bash shell and run the following command:

passwd

Enter your user account's current password, and then provide a new password.

To change another user account's password---for example, if you forgot your password and then set the root account as the default user account---you'd run the following command, where "username" is the username of the account whose password you want to change:

passwd username

This command must be run with root permissions, so you'll need to prefix it with sudo on Ubuntu if you're not running it as the root user:

sudo passwd username

How to Switch Between User Accounts

The ubuntu config --default-user username (or equivalent command for your Linux distribution) 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:

su username

You'll be prompted to enter the other user account's password, and then you'll be switched to that user account in the Bash shell.