13

WSL allows you to set the default version used by running wsl --set-default-version x (where x is the version to set the default to).

Is there any option to see what the current default version is? wsl --get-default-version is not recognized.

Mokubai
  • 89,133
  • 25
  • 207
  • 233
JohnLBevan
  • 656
  • 7
  • 14
  • 33

4 Answers4

12

Run the "wsl --status" command to check

$ wsl --status
tim
  • 121
  • 1
  • 2
8

The WSL default version is stored in a registry entry.

The key is stored at HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss in an entry named DefaultVersion. The value can either be 1 or 2.

To read the value in PowerShell, you can use the following:

Get-ItemPropertyValue `
      -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss `
      -Name DefaultVersion
Eric Cote
  • 206
  • 2
  • 3
  • It returns: ```Get-ItemPropertyValue : A propriedade DefaultVersion não existe no caminho HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss. No linha:1 caractere:1 + Get-ItemPropertyValue ` -Path HKCU:\SOFTWARE\Microsoft\Windows\Curren ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-ItemPropertyValue], PSArgumentException + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.GetItemPropertyValueCommand``` – Rodrigo Araujo Feb 10 '22 at 17:09
  • 1
    Rodrigo: The error means that no registry key was found. This happens when WSL isn't installed at all. – Eric Cote Aug 21 '22 at 16:54
7

WSL allows you to set the default version used by running wsl --set-default-version x (where x is the version to set the default to).

The command wsl --set-default-version 2 only exists if you have Windows 10 version 2004 installed. If you have any other supported version installed, you cannot change the default version, since it doesn't support multiple versions.

Is there any option to see what the current default version is? wsl --get-default-version is not recognized.

You are attempting to run a command that does not exists. Instead, you should be be running, wsl --list --verbose

You can check the WSL version assigned to each of the Linux distributions you have installed by opening the PowerShell command line and entering the command (only available in Windows Build 19041 or higher): wsl --list --verbose

Source: Set your distribution version to WSL 1 or WSL 2

Ramhound
  • 41,734
  • 35
  • 103
  • 130
1

As of today there is no flag to the command wsl that shows you which is the default version.

The answer from @Rahmound can help you get a feeling for the versions. Additionally it is true, that v1 is the default until you change it. But anyhow this both does not answer the question at hand and unfortunately it does not help on automation approaches just to mention one example.

Dominik
  • 113
  • 4