16

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.

0

4 Answers 4

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
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 Commented Feb 10, 2022 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
    Commented Aug 21, 2022 at 16:54
  • On my PC this key is empty and version can be found in the different key HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\{51415156-9f12-4486-8ee7-6736b91ab9b8}\Default Commented Nov 1, 2023 at 13:51
14

Run the "wsl --status" command to check

$ wsl --status

Default Version: 2

Windows Subsystem for Linux was last updated on 2023-10-20
WSL automatic updates are on.

Kernel version: 5.10.102.1
1
  • This command got stuck on some PC with WSL version 1, that is why I would prefer registry. Commented Nov 1, 2023 at 13:50
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

0
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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .