Skip to content

Instantly share code, notes, and snippets.

@ivermac
Last active March 31, 2024 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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 😄

@SBAI-Youness
Copy link

Worked perfectly, thank you so much!

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