Skip to content

Instantly share code, notes, and snippets.

@leodutra
Last active August 19, 2021 17:51
Show Gist options
  • Select an option

  • Save leodutra/6129e8aaac7d26d252aed38f3a7231a8 to your computer and use it in GitHub Desktop.

Select an option

Save leodutra/6129e8aaac7d26d252aed38f3a7231a8 to your computer and use it in GitHub Desktop.

Revisions

  1. leodutra revised this gist Aug 29, 2019. 1 changed file with 17 additions and 6 deletions.
    23 changes: 17 additions & 6 deletions enable-WSL2.ps1
    Original file line number Diff line number Diff line change
    @@ -2,11 +2,22 @@
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

    # list the available distros
    wsl --list
    # Use this command to convert a distro to use the WSL 2 architecture or use the WSL 1 architecture.
    # <Distro>: the specific Linux distro (e.g. “Ubuntu”)
    # <Version>: 1 or 2 (for WSL 1 or 2)
    # wsl --set-version <Distro> <Version>

    # set a distro to WSL 2
    # wsl --set-version DistroName 2
    # Changes the default install version (WSL 1 or 2) for new distributions.
    # wsl --set-default-version 2

    # set WSL 2 as the default
    wsl --set-default-version 2
    # Only list the distribution names.
    # This command is useful for scripting since it will only output the names of distributions you have installed without showing other information like the default distro, versions, etc.
    # wsl --list --quiet

    # Shows detailed information about all the distributions.
    # This command lists the name of each distro, what state the distro is in, and what version it is running. It also shows which distributions is default with an asterisk.
    # wsl --list --verbose

    # Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine.
    # The VM that powers WSL 2 distros is something that we aim to manage entirely for you, and so we spin it up when you need it and shut it down when you don’t. There could be cases where you would want to shut it down manually, and this command lets you do that by terminating all distributions and shutting down the WSL 2 VM.
    # wsl --shutdown
  2. leodutra revised this gist Aug 28, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion enable-WSL2.ps1
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-L
    Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

    # list the available distros
    wsl -l
    wsl --list

    # set a distro to WSL 2
    # wsl --set-version DistroName 2
  3. leodutra revised this gist Aug 28, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion enable-WSL2.ps1
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-L
    Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

    # list the available distros
    wsl -l -v
    wsl -l

    # set a distro to WSL 2
    # wsl --set-version DistroName 2
  4. leodutra revised this gist Aug 28, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions enable-WSL2.ps1
    Original file line number Diff line number Diff line change
    @@ -3,10 +3,10 @@ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-L
    Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

    # list the available distros
    # wsl -l -v
    wsl -l -v

    # set a distro to WSL 2
    # wsl --set-version DistroName 2

    # set WSL 2 as the default
    # wsl --set-default-version 2
    wsl --set-default-version 2
  5. leodutra created this gist Aug 28, 2019.
    12 changes: 12 additions & 0 deletions enable-WSL2.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # AS ADMIN
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

    # list the available distros
    # wsl -l -v

    # set a distro to WSL 2
    # wsl --set-version DistroName 2

    # set WSL 2 as the default
    # wsl --set-default-version 2