WSL icon indicating copy to clipboard operation
WSL copied to clipboard

After distro has been imported from backup it opens with root user

Open vyushin opened this issue 4 years ago • 5 comments

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

  1. Make file in ~\.wslconfig
  2. Put to file:
[user]
default=evgeny
  1. Install distro, create a user with name evgeny
wsl --install -d Ubuntu-18.04
  1. Make sure, that the distro opens with default user evgeny
 wsl -d Ubuntu-18.04
  1. Shutdown
wsl --shutdown
  1. Make backup
wsl --export Ubuntu-18.04 Ubuntu-18.04_backup
  1. Unregister the distro
wsl --unregister Ubuntu-18.04
  1. Make suer the distro unregistered
wsl -l -v
  1. Import the distro from backup (replace evgeny to your username)
wsl --import Ubuntu-18.04 C:\Users\evgeny\WSL\Ubuntu-18.04 C:\Users\evgeny\Ubuntu-18.04_backup
  1. Make sure that the distro imported
wsl -l -v
  1. 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 avatar Jan 01 '22 21:01 vyushin

@vyushin set the default user in /etc/wsl.conf (create file if not present) before exporting your distro.

elsaco avatar Jan 01 '22 22:01 elsaco

@elsaco, exactly before exporting? Do you mean that if i create /etc/wsl.conf after importing then default user won't set?

vyushin avatar Jan 01 '22 23:01 vyushin

@elsaco, I have this. In this case wsl.conf have been made after the distro have been imported. image

vyushin avatar Jan 01 '22 23:01 vyushin

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.

elsaco avatar Jan 01 '22 23:01 elsaco

In this case try:

wsl --terminate
ubuntu1804 config --default-user evgeny

This is working for me. Thank you!

vyushin avatar Jan 02 '22 10:01 vyushin