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.

  • 5
    As of now, Ubuntu 20.04 is current. After its installed using WSL 2, the ubuntu2004 command becomes available for use: ubuntu2004 config --default-user robert
    – BSalita
    Commented Jun 23, 2020 at 11:18
  • 5
    For those who didn't installed via store (e.g via export/import): github.com/microsoft/WSL/issues/3974#issuecomment-576782860. Default user can be changed by creating a /etc/wsl.conf file Commented Nov 3, 2020 at 12:27
  • Thanks so much @SebastianHoffmann, this comment is what made me realise that it was all due to the import. Thought when I exported that everything would be an exact copy, but I guess not.
    – EmSixTeen
    Commented Jan 21, 2021 at 13:17

9 Answers 9


Now that LxRun.exe is deprecated, if you install Ubuntu from the Windows store the command you will need to run at a windows command prompt is

ubuntu config --default-user <username>

(Note: depending on which version you installed this could be ubuntu1804.exe or ubuntu2004.exe)

If you're using WSL2, you're done.

For WSL1, you'll need to also restart LxssManager service

sc stop LxssManager
sc start LxssManager
  • 6
    ubuntu might NOT be your default, it depends which version you installed so check the answers below, as mine is "ubuntu1804 config ..."
    – rmcsharry
    Commented Apr 25, 2019 at 11:01
  • 9
    ubuntu1804 config --default-user ... for me
    – masterxilo
    Commented Jul 11, 2019 at 18:13
  • 1
    Is there a way to do this same action but using the 'bash' command?
    – rmutalik
    Commented Dec 2, 2019 at 19:07
  • 1
    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
    Commented Dec 4, 2019 at 17:09
  • 2
    With WSL 2 in use, it was not required to restart the LxSSManager service for the container to use the change
    – Laice
    Commented Aug 23, 2021 at 12:01

The top answer (ubuntu config --default-user root) is currently correct for the default instance. But if you have multiple instances, you need to work slightly harder:

Inside the instance, as root, create/edit /etc/wsl.conf and add these lines:


Then close it, run wsl --terminate <distro name> in PowerShell, and restart it.

That's from an issue in the WSL repo. The registry hack answer is also in there, but /etc/wsl.conf is now officially the supported solution.

  • 8
    For the ones who have moved the distro file from C to other drive like me. This worked in a go.
    – Asif Ali
    Commented Dec 17, 2020 at 8:41
  • 4
    This should be the accepted answer as this also works for custom installed distributions.
    – papercrane
    Commented Jan 29, 2021 at 19:22
  • 4
    This works for my distro that was moved to another drive using wsl --export and wsl --import Commented Mar 24, 2021 at 15:45
  • 2
    I needed to change my default user from root to my own user and this was the answer. Commented Jul 11, 2021 at 5:01
  • 1
    /etc/wsl.conf solution worked for me
    – Adil
    Commented Jul 13, 2021 at 12:53

All other answers were helpful, but can be other scenarios too, follow here as per yours. Mine was Ubuntu 16.04, so I used the following:

ubuntu1604 config --default-user <username>

If you installed Ubuntu 18.04:

ubuntu1804 config --default-user <username>

If you used the default one, then:

ubuntu config --default-user <username>
  • 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
    Commented Apr 26, 2019 at 17:09
  • U may want to use root as user??
    – kakabali
    Commented Jun 27, 2019 at 3:50
  • 1
    this should be the ANSWER, today at 2020-02-15, this is the only option works.
    – Luke
    Commented Feb 15, 2020 at 2:24
  • The right answer as I have two Ubuntus! You have yo specify.
    – raphaklaus
    Commented Nov 4, 2022 at 20:11

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

ubuntu1804 config --default-user <username>

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>

Old question that got bumped today, but the answers need updating and consolidating to be current (and correct).

There are two parts to the question, and every answer here so far just covers one or the other.

First question:

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

As @PJ127 correctly pointed out, the first step is to actually change the username within Ubuntu. This can most easily be done (now, in 2021) by exiting WSL and starting PowerShell, then:

wsl -l -v
wsl --terminate <distro> # <distro> from the previous command
wsl -u root -d <distro> # "-d <distro>" is only needed for non-default instances
# Now from in WSL
usermod -l newname oldname 
# Optionally change the home directory name to match
usermod -d /home/doug -m doug
# Optionally change the group name to match
groupmod -n newname oldname

Then there's the second part of the question, which is what most of the answers here attempt to cover:

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

There are multiple ways of doing this, but the Microsoft recommended/documented method in 2021 is as @Jacktose answered:

  • In your WSL instance, sudo editor /etc/wsl.conf with the following contents:


    Exit, then from PowerShell, wsl --terminate <distro name> and restart WSL.

While the ubuntu.exe --config method will work, there are two problems:

  • It's not always "ubuntu.exe". The name of the executable (technically "app execution alias") depends on which version you installed from the Store. Ubuntu has come in multiple Store packages over the years. There's a package for each supported release (e.g. ubuntu2004.exe, etc.) and one for the "current" version (ubuntu.exe). And while this is Ask Ubuntu, it also could be alpine.exe, etc. if you are using a different distribution.

  • It also, as has been pointed out in other answers, does not work if you have more than one instance installed (which is a great feature of WSL). It will only work for the first, store-installed instance.

Then, of course, there are registry-based methods of changing the default name, but since we have safer, supported methods let's not even cover those here. :-)

  • Setting the default user didn't work for me until I added that user. Now it works like a charm. (WSL with VS Code just used root, no additional user was added until I did this)
    – ps2goat
    Commented Apr 5, 2022 at 16:50


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


ubuntu was not recognized by cmd.exe (Windows 10 / WSL Ubuntu 20.04), so the solutions above did not work for me.

What worked for me (from Windows terminal):

wsl.exe -u root
sudo usermod -l newUsername oldUsername
sudo usermod -d /home/newHomeDir -m newUsername
  • This is the correct answear, because it is changing the username, not the user itself. Also, if you get the message that username can't be changed because a process is running, just sudo kill processId Commented Jun 25, 2021 at 16:46
  • 1
    And you also probably want to change the group name 'sudo groupmod -n newUsername oldUsername' Commented Jul 1, 2021 at 0:37

Use wsl --list command to see what WSL distribution you have installed. It may return Ubuntu-22.04 or some other version you may have installed. Alternatively you can run the following from WSL Ubuntu terminal session to get your Ubuntu version:

grep "DISTRIB_RELEASE=" /etc/lsb-release | grep -E [0-9]{2}.[0-9]{2} -o

Having Ubuntu version clarified run the command below from Windows CMD to set your default user, making sure that replacing 2204 to the specific version you have (obtained using commands above):

ubuntu2204 config --default-user <username>
  • 2
    This looks to be exactly the same information that was already given in this answer from 5 years ago. While we welcome new answers to old questions, we do ask that they be new ;-). If you are just adding the ubuntu2204 for the latest release, then that should be a simple edit to the existing answer. If you'd like to make that edit, I'd be happy to approve it for you. Thanks! Commented Dec 2, 2022 at 12:27
  • Well I explicitly added on how to get Ubuntu version used instead of listing couple of versions to be common at the moment of the answer. that was the only new part... I didn't noticed that part covered in other answers so decided to add mine
    – Mike
    Commented Dec 2, 2022 at 14:01
  • 2
    Understood - Just looks like information that should probably have been edited in to the other answer. Sometimes it's a tough call, I know. But look at the other similar edits that other users have made to that answer. Commented Dec 2, 2022 at 14:04
  • When building on other people's answers it is important to give credit. These purpose of these communities is to share knowledge therefore it is important to link duplicate or similar answers.
    – theYnot
    Commented Dec 9, 2022 at 21:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .