Skip to content

Instantly share code, notes, and snippets.

@mkol5222
Forked from netfantom-spb/WSL.md
Created September 18, 2025 11:04
Show Gist options
  • Save mkol5222/ae7e44a672defa9467d57ad1c2b1d5e5 to your computer and use it in GitHub Desktop.
Save mkol5222/ae7e44a672defa9467d57ad1c2b1d5e5 to your computer and use it in GitHub Desktop.
WSL

WSL list

Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss" -Recurse

Move WSL to another drive/PC

wsl --export Ubuntu .\Ubuntu\ext4.vhdx --vhd
wsl --unregister Ubuntu
wsl --import-in-place Ubuntu .\Ubuntu\ext4.vhdx

After export and import, the new instance will use root by default. If you want to continue to use that user, please configure it via registry table.

Find the directory in registry HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss which DistributionName is “Ubuntu”. Set its DefaultUid to decimal 1000 (or hex 3e8).

Set default user on login

/etc/wsl.con

[user]
default=username
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment