Enable WSL 2 in Win10

Turn on Hyper-V

Control Panel -> Turn on / off Windowns Function -> Tick Hyper-V platform

image.png

Activate WSL

Run below 2 commands in Powersell in Admin mode

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

WSL should be enabled now.

image.png

Install Linux Distribution via MicroSoft App Store

After install successfully, click Open and create your own profile.

image.png

Connect to Linux system

wsl -l to locate the distrubtion wsl -d Ubuntu-20.04 to connect to the sub-system

bobgo@DESKTOP-EBQ26SR:/f/dev/java/javaHello
$ wsl -l
适用于 Linux 的 Windows 子系统分发版:
Ubuntu-20.04 (默认)

bobgo@DESKTOP-EBQ26SR:/f/dev/java/javaHello
$ wsl -d Ubuntu-20.04
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

sam@DESKTOP-EBQ26SR:/mnt/f/dev/java/javaHello$

Ref