25

I installed the WSL Bash on Windows 10 and set my user to e.g. 'abc' but now I want to change it to something else.

How can I change the user name of the user I'm logged in as?

When I open bash it automatically logs me in with my current user.

35

Now that LxRun.exe is deprecated, if you install Ubuntu from the Windows store the command you will need is

ubuntu config --default-user <username>

Restart LxssManager service

sc stop LxssManager
sc start LxssManager
  • 2
    ubuntu might NOT be your default, it depends which version you installed so check the answers below, as mine is "ubuntu1804 config ..." – rmcsharry Apr 25 '19 at 11:01
  • 2
    ubuntu1804 config --default-user ... for me – masterxilo Jul 11 '19 at 18:13
  • Restarting the service was a must for me. Googled a few minutes before I found this, no one really mentions it. Thanks! – jValdron Sep 11 '19 at 11:39
  • Is there a way to do this same action but using the 'bash' command? – rmutalik Dec 2 '19 at 19:07
  • instead of setting the default user it opened bash for me. It does not seem to be working for some reason. I am on the latest release of Windows as of today – akxer Dec 4 '19 at 17:09
14

All other answers were helpful, but can be other scenarios too, follow here as per yours. Mine was ubuntu 1604, so used following:-

ubuntu1604 config --default-user <username>

if you installed ubuntu 1804:-

ubuntu1804 config --default-user <username>

if you used default one, then:-

ubuntu config --default-user <username>

  • Why was this at 0 votes? Its exactly what you need to do if you don't install the default Ubuntu. – Kory Mar 8 '19 at 7:20
  • yes it should have had some better vote counts :-) – kakabali Mar 8 '19 at 15:15
  • Should this not change the current username to the username I provide in <username>? When I try this it just tells me the username I am providing does not exist. This is on 18.0.4 – wuno Apr 26 '19 at 17:09
  • U may want to use root as user?? – kakabali Jun 27 '19 at 3:50
  • 1
    this should be the ANSWER, today at 2020-02-15, this is the only option works. – Luke Feb 15 at 2:24
13

You can change the default user for bash by running the following command in a normal command prompt (cmd.exe):

LxRun.exe /setdefaultuser <new_name>
8

If you're running Ubuntu 18.04 from the Microsoft Store, the command (powershell or cmd) will be:

ubuntu1804 config --default-user <username>

1

In CMD

See which distros you have installed wslconfig /l

I have Ubuntu and I wanted to set the default user to root ubuntu config --default-user root

Documentation: https://docs.microsoft.com/en-us/windows/wsl/user-support

  • Why nominate to delete? – Benjamin McIntire Jan 22 '19 at 4:46
  • Likely because this answer (or near to) has already been posited by three people. If you are adding information to existing answers (e.g. the bit about wslconfig), SE expects you to edit an existing answer. – timelmer Feb 10 at 18:58
  • I mean, if that was clear to me at the time I would have done that. A delete nomination is a super derptastic way of asking for that to be done. – Benjamin McIntire Feb 10 at 23:58
  • I agree that an explanation should've been provided, but you also should have noticed that other; very similar; answers existed. Take it as a learning experience, I suppose. – timelmer Feb 11 at 0:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.