Skip to content

Instantly share code, notes, and snippets.

@ivermac
Last active July 2, 2025 23:25
Show Gist options
  • Save ivermac/471bced069c3928e4033c4c7522b57c1 to your computer and use it in GitHub Desktop.
Save ivermac/471bced069c3928e4033c4c7522b57c1 to your computer and use it in GitHub Desktop.
Renaming user in ubuntu when using WSL2

Recently (well a couple of hours ago πŸ˜†) I installed Ubuntu 22.04 on my WSL2 but I misspelled my username and I had to ( wanted to is more accurate πŸ˜†) change to my preferred username. I got all my insights from here and here.

 wsl -d ubuntu-22.04 -u root usermod -l <new-username> <old-username>
 wsl -d ubuntu-22.04 -u root groupmod -n <new-groupname> <old-groupname>
 wsl -d ubuntu-22.04 -u root usermod -d /home/<new-home-directory> -m <new-username>

I got excited this worked the first time and I wanted to write about it πŸ˜„

@mmzvia
Copy link

mmzvia commented Oct 13, 2024

thanks!

@Muhammad-Jafar
Copy link

cool, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment