Skip to content

Instantly share code, notes, and snippets.

@hoangitk
Last active September 28, 2025 04:28
Show Gist options
  • Select an option

  • Save hoangitk/e9e8a1a980ffda2d8d8defd308d7c8bd to your computer and use it in GitHub Desktop.

Select an option

Save hoangitk/e9e8a1a980ffda2d8d8defd308d7c8bd to your computer and use it in GitHub Desktop.
[WSL] #wsl

WSL

Command

  • List all distros
wsl -l -v
  • List distro location
(Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | ForEach-Object {Get-ItemProperty $_.PSPath}) | select DistributionName,BasePath,VhdFileName

Move distro to other location

  1. Shutdown all WSL distros
wsl --shutdown
  1. Export distro to tar file
wsl --export <distro-name> d:\wsl\export\<distro-name>.tar
  1. Unregister the distro
wsl --unregister <distro-name>
  1. Import from tar file
wsl --import <distro-name> d:\wsl\<distro-name> d:\wsl\export\<distro-name>.tar --version 2

Move distro to other location (2)

cd D:\
mkdir WSL
cd WSL
wsl --export Ubuntu ubuntu.tar
wsl --unregister Ubuntu
mkdir Ubuntu
wsl --import Ubuntu Ubuntu ubuntu.tar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment