Useful commands for WSL2

  • To verify the WSL version:
    powershell
    wsl --list --verbose
    
  • To view installed distro list:
    powershell
    wsl --list
    
  • To change the default distro:
    powershell
    wsl --set-default <distro_name>
    
  • To launch a distro:
    powershell
    wsl -d <distro_name>
    
  • To launch the default distro:
    powershell
    wsl
    
  • To launch a distro with a specific user:
    powershell
    wsl -d <distro_name> -u <user_name>
    
  • To launch a command in a distro:
    powershell
    wsl -d <distro_name> -e <command>
    
  • To lanch a distro in a specific directory:
    powershell
    wsl -d <distro_name> -w <directory>
    
  • To uninstall a distro:
    powershell
    wsl --unregister <distro_name>