How to change user accounts in Ubuntu Bash Shell Windows 10
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
- How user accounts work in Linux environment
- How to change the default user account for Bash
- How to create a new user account in Bash
- How to change Bash user account password
- 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.
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.
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:
- 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 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.
- 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 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 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 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.
Good luck!
See more:
- Basic Shell commands in Linux
- Shell Sort in data structure and algorithm
- Shell functions
You should read it
- Everything you can do with the new Windows 10 Bash Shell
- Instructions for accessing Ubuntu Bash files on Windows
- How to use Zsh (or other Shells) on Windows 10?
- What is 'Bash' in Linux?
- Ubuntu Bash tutorial on Windows 10
- What is Linux Shell? The most popular Linux Shells
- How to create and open folders in VS Code with Git Bash for Windows
- Difference between Zsh and Bash
- How to create and run a shell script in Ubuntu 20.04 LTS
- How to Install and Run Bash on Windows 11
- Shortcuts to copy - paste coming soon on Windows 10's Bash Console
- How to change the default shell in Windows Terminal
Maybe you are interested
This is the culprit that prevents users from updating Windows 11 24H2
How to switch users on the Linux command line
4 reasons why users are looking forward to the Samsung Galaxy S25 Ultra
5 things Pro users may have to give up to switch to iPhone 17 Air
Mozilla quietly adds user tracking feature in new Firefox update
8 Windows 11 features that make users decide to give up Windows 10