The first time you install Ubuntu or another Linux distribution on Windows 10, you are asked to create a UNIX username and password so when you launch the shell, Bash signs into that user account automatically.
How User Accounts Work in the Linux Environment
If you set up a new Linux distribution by launching it after installing it, you’ll be asked to create a user account for the Bash shell. This account is your “UNIX user account.” If you provide the name “bob” and the password “letmein,” your Linux user account is named “bob” and the home folder being “/home/bob.” When you wish to enter your password in the shell, you must enter “letmein.” These credentials are entirely seperate from your Windows user account and password.
All installed Linux environments have their own configuration, be it separate files, installed programs, and configuration settings. A UNIX username and password for every Linux distribution must be created.
How to Change Your Default User Account for Bash
First, 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 instance, to set the default user as root, run the following command. This is useful 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 while in 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 for authentication, 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.)
Further information will be required, say, 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.
Once 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 need to use normal Linux commands inside the Bash environment. To change the current user account’s password, launch a Bash shell and run the following command:
Enter your user account’s current password, and then provide a new password.
To change another user account’s password in case you forgot your password and then set the root account as the default user account, run the command below, where “username” is the username of the account whose password you want to change:
This command must be run with root permissions, so you must 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 within 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 be switched to that user account in the Bash shell.