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 π
Worked perfectly, thank you so much!