Skip to content

Instantly share code, notes, and snippets.

@netfantom-spb
Last active September 18, 2025 11:04
Show Gist options
  • Save netfantom-spb/8d87088d4fe7a9f602e3326c332920e3 to your computer and use it in GitHub Desktop.
Save netfantom-spb/8d87088d4fe7a9f602e3326c332920e3 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