Change username on Ubuntu(usermod: user * is currently used by process *) [duplicate]

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.


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)

Restart LxssManager service

sc stop LxssManager
sc start LxssManager

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:

[user]
default=username

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.


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>

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>