Open PowerShell
as Administrator
Enable the Windows Subsystem for Linux
optional component
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
To install WSL, your Windows 10 must be at least version 2004
. Run winver
to check you windows version, and run Windows Update if required.
Enable the Virtual Machine Platform
optional component
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Set WSL 2 as your default version
wsl --set-default-version 2
If it show Invalid command line option: --set-default-version
, it probably means you are on WSL1 (where you Windows is less than version 2004
)
If it show
WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel
Follow the instruction to install Linux kernel update package
.
If successful, it will show
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Visit Microsoft Store to install Ubuntu. I select Ubuntu 20.04 LTS
.
Installing, this may take a few minutes...The Windows Subsystem for Linux instance has terminated.Please create a default UNIX user account. The username does not need to match your Windows username.For more information visit: https://aka.ms/wslusersEnter new UNIX username: New password:Retype new password:passwd: password updated successfullyInstallation successful!
You might want to update Ubuntu and its packages
sudo apt-get update && sudo apt-get upgrade
You can check you WSL version through PowerShell
wsl --list --verbose NAME STATE VERSION* Ubuntu-20.04 Running 2
References: