The fastest way to change your WSL Ubuntu username

To change your username in WSL Ubuntu, you need to log in as root, rename your user account, and update the home directory name to match. The process takes about five minutes and requires only three terminal commands. You do not need to reinstall Ubuntu or create a new WSL instance.

The reason you need root access is that your user account owns files and processes that only the root user can rename. WSL Ubuntu comes with root access built in — you can switch to it when ready by typing sudo su at any prompt.

Key Takeaways

  • Switch to root by typing sudo su, then use the usermod command to rename your account and move your home directory in one step.
  • The command is usermod -d /home/newname -m -l newname oldname, where you replace oldname with your current username and newname with what you want.
  • After renaming, log out completely, close WSL, and reopen it to see the change take effect in your terminal prompt.
  • If you forget your current username, type whoami to see it displayed when ready.

Step 1: Open WSL Ubuntu and switch to root

Launch WSL Ubuntu from your Start menu or by typing wsl in PowerShell. You will see a terminal prompt that ends with a dollar sign ($) and shows your current username.

Type sudo su and press Enter. The terminal will ask for your password — type it (the characters will not appear on screen, which is normal). After you press Enter, your prompt will change to a hash symbol (#), which means you are now root and can rename any user account.

Step 2: Rename the user account and home directory together

At the root prompt, type the following command all on one line, replacing oldname with your current username and newname with the username you want:

usermod -d /home/newname -m -l newname oldname

Press Enter. The command will run silently — if nothing appears on the next line, the rename succeeded. If you see an error like "user oldname does not exist", check that you typed your current username correctly by typing whoami first.

The -l flag renames the account itself. The -d /home/newname flag tells the system where the home directory should be. The -m flag moves all your files from the old home directory to the new one automatically.

Step 3: Log out and close WSL to explore the change

Type exit and press Enter to leave the root session. Type exit again to log out of your user account completely. The terminal window will close.

Close WSL entirely — you can close the terminal window or type wsl --terminate Ubuntu in PowerShell to shut it down cleanly. This forces WSL to reload your user settings the next time you open it.

Step 4: Reopen WSL and verify the change

Open WSL Ubuntu again from the Start menu. Look at the terminal prompt — it should now show your new username instead of the old one. Type whoami to confirm the change took effect.

Check that your files are still there by typing ls to list your home directory. All your documents, downloads, and other files should be present because the -m flag moved them when you renamed the account.

What to do if the rename failed

If you see an error message, the most common cause is that you typed the old username incorrectly. Type whoami to see your current username exactly as the system knows it, then try the usermod command again with the correct spelling.

If you see "user is currently logged in", it means you are still running processes under the old username. Type exit twice to log out completely, close the terminal window, and try again after reopening WSL.

If the rename command ran but your prompt still shows the old username after you reopen WSL, restart your computer. WSL sometimes caches the old username in memory and needs a full restart to refresh it.

Changing your username back to the default

WSL Ubuntu's default username is usually root or a name you chose during first setup. If you want to revert to that name, follow the same steps but swap the old and new names in the usermod command.

For example, if you renamed yourself from root to marcus and now want to change back, the command would be usermod -d /home/root -m -l root marcus. You will need to switch to root access first using sudo su, which may require you to know the password you set during Ubuntu installation.

Frequently Asked Questions

Can I change my username without losing my files?

Yes. The -m flag in the usermod command moves your entire home directory and all files inside it to the new location. Your documents, settings, and everything else stays intact.

What if I do not know my current username?

Type whoami at any prompt and press Enter. The system will display your current username when ready. Use this name as the oldname in the usermod command.

Do I need to reinstall Ubuntu to change my username?

No. The usermod command changes the username in place without touching the Ubuntu installation itself. Your WSL instance, all your files, and all your settings remain exactly as they are.

Why does my prompt still show the old username after I rename?

Your terminal session is still using the old username in memory. Close the terminal window completely, then reopen WSL. If it still shows the old name, restart your computer — WSL sometimes needs a full reboot to refresh cached usernames.

Can I use special characters or spaces in my new username?

Linux usernames should contain only lowercase letters, numbers, underscores, and hyphens. Spaces and special characters like @ or ! will cause the rename to fail. Keep your new username straightforward and lowercase.