After distro has been imported from backup it opens with root user
Version
Microsoft Windows [Version 10.0.22000.376]
WSL Version
- [X] WSL 2
- [ ] WSL 1
Kernel Version
5.10.60.1
Distro Version
Ubuntu 18.04
Other Software
No response
Repro Steps
- Make file in
~\.wslconfig - Put to file:
[user]
default=evgeny
- Install distro, create a user with name
evgeny
wsl --install -d Ubuntu-18.04
- Make sure, that the distro opens with default user
evgeny
wsl -d Ubuntu-18.04
- Shutdown
wsl --shutdown
- Make backup
wsl --export Ubuntu-18.04 Ubuntu-18.04_backup
- Unregister the distro
wsl --unregister Ubuntu-18.04
- Make suer the distro unregistered
wsl -l -v
- Import the distro from backup (replace
evgenyto your username)
wsl --import Ubuntu-18.04 C:\Users\evgeny\WSL\Ubuntu-18.04 C:\Users\evgeny\Ubuntu-18.04_backup
- Make sure that the distro imported
wsl -l -v
- Run the distro
wsl -d Ubuntu-18.04
Expected Behavior
The imported distro have to opens with default user evgeny because .wslconfig contains this rule
Actual Behavior
The imported distro opens with root user by default
Diagnostic Logs
No response
@vyushin set the default user in /etc/wsl.conf (create file if not present) before exporting your distro.
@elsaco, exactly before exporting? Do you mean that if i create /etc/wsl.conf after importing then default user won't set?
@elsaco, I have this. In this case wsl.conf have been made after the distro have been imported.

In this case try:
wsl --terminate
ubuntu1804 config --default-user evgeny
And, yes, the default username must be set in /etc/wsl.conf before export. The setting will stick around when you export/import later on.
In this case try:
wsl --terminate
ubuntu1804 config --default-user evgeny
This is working for me. Thank you!