agowa / WSL-DistroLauncher-Alpine

Alpine WSL Microsoft Store packages.
MIT License
214 stars 29 forks source link

how to set default user #51

Closed draylegend closed 1 year ago

draylegend commented 1 year ago

How to set a default user after export and import?

Steps:

wsl --export alpine d:\wsl\custom-alpine.tar wsl --import custom-alpine d:\wsl\ d:\wsl\custom-alpine.tar

Error

I tried to use wsl -d custom-alpine config --set-default-user bosss but I get /bin/ash: config: Permission denied.

agowa commented 1 year ago

Sorry, but if you use export and import, you're on your own, as you don't use the wrapper, and this GitHub project is just the wrapper. This is probably a question for Microsoft.

Nonetheless, you can look at https://github.com/agowa338/WSL-DistroLauncher-Alpine/blob/master/DistroLauncher/DistroSpecial.h#L23 to see what customizations my wrapper does.

Also, your wsl command is wrong. You're telling it to execute a binary named "config" with the argument "--set-default-user bosss" within the Alpine environment. And the error message is the shell ash reporting that such a binary does not exist.

My guess is that you're trying to use the config parameter of the wrapper (https://github.com/agowa338/WSL-DistroLauncher-Alpine/blob/master/DistroLauncher/DistroLauncher.h#L4). The generic "wsl.exe" does not have that option. So you'd need to either build your own wrapper (this project with your own tar) or find another way.

agowa commented 1 year ago

Here is the Stack Exchange answer: https://superuser.com/a/1627461

Tl;Dr: As I said, not possible with wsl.exe, but alternatives exist.

1) /etc/wsl.conf with

[user]
default=username

2) Setting DefaultUid in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\{$GUID}