Windows 10 Linux Subsystem How to Change User Name and PC Name for Bash Console

When I first installed and ran Windows Linux Subsystem, console askded me to enter a new user name for bash. I input User. Now when I start bash in my console my username and PC name appeared at the beginning of the prompt, like

User@DESKTOP-TPQIRNP:/mnt/...


What should I do if I want to change my username for bash console? And PC name

• You change the PC Name in Windows, same way you have always done so, how you change the username your logged into should be simply su'ing as that user. – Ramhound Aug 5 '16 at 7:23
• @Ramhound Thanks. But how to change user name for bash ? If I will change user name in windows it's don't change in bash console – Mikhail Aug 5 '16 at 7:25
• If you have changed the PC Name, and your Windows username, and it isn't showing up in bash then you will have to reset the environment. I already suggest how you switch users within bash though. – Ramhound Aug 5 '16 at 7:27
• You can switch "hosts" by simply using ssh hostname. Look at the configuration page to determine what your current hosts are. Two should already exist, the one your currently trying to access and the one you previously created. – Ramhound Aug 5 '16 at 7:36

According to therobyouknow's comment, LxRun.exe is deprecated now.

Please refer to Mitchell Van Manen's answer if you're using the new version of subsystem.

====================================================================

You should use LxRun.exe command locating in C:\WINDOWS\system32.

Here are two solutions, which are all run in cmd.exe instead of bash.

• Use the command below to create a new user and set it as the default user:

LxRun.exe /setdefaultuser NEW_USER

• OR Uninstall Linux subsystem fully and reinstall it

LxRun.exe /uninstall /full
LxRun.exe /install


The next time you reenter bash, it will prompt you to input username.

• For a newer version of the subsystem (i.e. one downloaded/upgraded-to as of date of this comment), one would need use the answer provided by @Mitchell Van Manen - superuser.com/a/1280390/21353 (I found that answer to work). Otherwise you get: Warning: lxrun.exe is only used to configure the legacy Windows Subsystem for Linux distribution – therobyouknow May 22 '18 at 18:36
• @therobyouknow thanks for the reminder! I've updated my answer. – oryxfea May 23 '18 at 2:17
• You're welcome +1 upvote on your comment oryxfea and answer and also +1 upvote on Mitchell Van Manen's answer. Thank you. – therobyouknow May 23 '18 at 11:59

In the new version of the subsystem, the command is (from elevated cmd.exe):

C:\> ubuntu run sudo usermod -l newUsername oldUsername

this way you will circumvent logging in with the old username first.

• This solved it for me with the newer version of subsystem. – bcar Jan 11 '18 at 17:06
• C:\> ubuntu run sudo usermod -l newUsername -p /home/newUsername -m oldUsername also renames home folder – Pav K. Oct 10 '18 at 13:04
• @PavK. I believe there's a typo in your answer: The "-p" (which is for passwords) should be "-d" (which is for changing the home directory). At least that was what worked on my system. – IvyMike Oct 20 '20 at 21:00

You have to create a ssh_config and put your username into it. The location within the Windows Linux Subsystem is /mnt/%windir%/windows
Create ~/.ssh/config file and name write your username inside the file like:
user New_User_Name

• Thanks. When I should create ~/.ssh/config file ? Where in Windows is root Windows Linux Subsystem directory ? How can I find it ? – Mikhail Aug 5 '16 at 7:41
• it's /mnt/%windir%/windows – phuclv Aug 5 '16 at 8:53