0

I've imported a WSL image I had exported from WSL previously (wsl --import UbuntuTest ./UbuntuImport .\UbuntuSnapshot201011).

My distro has been correctly installed as UbuntuTest. However, when I log into it with wsl -d UbuntuTest the default user is root, and not roemerco. I would like to change it, so that I can login just with wsl -d UbuntuTest not needing the CLI option -u roemerco in addition.

Apparently, for many users, it's possible to change default users by running a command like ubuntu config --default-user <username> (see How to change default user in WSL Ubuntu bash on Windows 10). However, this doesn't work in my case. Neither on CMD nor Powershell is ubuntu or ubuntu2004 a recognised command. This may be, because I haven't installed the distro through the Microsoft Store.

Does anyone have any thoughts? I tried to find stuff in the WSL docu, but couldn't find anything about it. Is this a missing feature or bug?

1 Answers1

3

Actually there's a much discussed issue for exactly my problem on WSL Github. There are two methods to solve the problem: a) registry hack, b) editing a config file. The powershell registry hack worked for me:

Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName `
| Where-Object -Property DistributionName -eq UbuntuTest `
| Set-ItemProperty -Name DefaultUid -Value 1000

Replace UbuntuTest with your respective distro name.