How to change user accounts in Ubuntu Bash Shell Windows 10

Bash automatically logs in to that user account when you launch the shell. However, you can change those login information if needed.

When you first install Ubuntu or another Linux distribution on Windows 10, you are required to create a UNIX username and password. Bash automatically logs in to that user account when you launch the shell. However, you can change those login information if needed.

How to change user accounts in Ubuntu Bash Shell Windows 10

  1. How user accounts work in Linux environment
  2. How to change the default user account for Bash
  3. How to create a new user account in Bash
  4. How to change Bash user account password
  5. How to switch between user accounts

How user accounts work in Linux environment

When you set up a new Linux distribution by launching it after installation, you will 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 will have the name 'bob' and have the main directory '/ home / bob.' When you need to enter the password in the shell, you must enter "letmein". These logins are completely independent of your Windows user account and password.

How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 1How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 1

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

How to change the default user account for Bash

To change the default user account in Ubuntu Bash shell, open the Command Prompt window or the PowerShell window.

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

How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 2How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 2

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

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

You can only specify user accounts that already exist in the Linux environment.

For example, to set the default user to root, run the following command. This is convenient if you forget your UNIX user account password, since root users have full access to the system. You will be able to create a new user account and reset the password for your current user account from the root shell.

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

How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 3How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 3

How to create a new user account in Bash

You can create user accounts by running the adduser command from within the Bash shell of the Linux environment. For example, to do this on Ubuntu, simply run the following command, replacing 'newuser' with your new user account name:

 sudo adduser newuser 

Provide your current user account password for authentication and then enter the password for the new user account. (If you do not remember your current UNIX account password, use the commands described in the previous section to set the root user as the default user account first).

You will also be asked to provide other information, such as "full name" and phone number for the new account, all of which is stored locally on your computer and is not important. You just need to press Enter to leave these fields blank.

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

How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 4How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 4

How to change Bash user account password

To change the Bash user account password, you will need to use normal Linux commands within the Bash environment. To change the password of the current user account, you will launch a Bash shell and run the following command:

 passwd 

Enter the current user account password and then provide the new password.

To change the password of another user account - for example, if you forget the password and then set the root account as the default user account - you'll run the following command, where 'username' is the username account has the password you want to change:

 passwd username 

This command must be run as root, so you will need to prefix it with sudo on Ubuntu, if you do not run it as root user:

 sudo passwd username 

How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 5How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 5

How to switch between user accounts

User name config --default-user on Ubuntu (or the equivalent command for your Linux distribution) controls which user account the Bash shell will use by default. However, if you want to use multiple user accounts with Bash, you can switch between accounts while in a Bash shell.

To do this, run the following command in the Bash shell, replace "username" with the username you want to use:

 su username 

You will be prompted to enter the password of another user account and then you will be transferred to that user account in the Bash shell.

How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 6How to change user accounts in Ubuntu Bash Shell Windows 10 Picture 6

Good luck!

See more:

  1. Basic Shell commands in Linux
  2. Shell Sort in data structure and algorithm
  3. Shell functions
3.6 ★ | 5 Vote