Windows Subsystem for Linux (WSL) allows users to run the Linux Operating system directly on Windows 10. In this article, I will show you how to enable WSL 2 and install Ubuntu. In May 2019 Microsoft announced WSL 2 which has better performance than WSL1.
For WSL 2, you require a 64 Bit Window 10 Version 1903 or higher and make sure your PC support Hyper-V Virtualization support.
To check your current windows build version select Windows logo key + R, type winver, select OK.
Note: From Windows 10 Insiders Preview build 20246, you install your Linux distro in one single step, run:
wsl.exe --install -d Ubuntu-20.04
Step 1) Enable WSL in Windows 10
To enable WSL, you must enable the feature "Windows Subsystem for Linux". Open your PowerShell as an administrator, run:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
This will enable WSl 1, if you want to set WSL 2 continue to the next step.
Note: You can upgrade WSL1 distribution to WSL 2 directly using 'wsl.exe --set-version <distro-name> 2'.
Step 2) Enable Virtual Machine
To enable virtual machine on windows 10 (2004) run the following command in Powershell ( as administrator):
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
On Windows 10 (1903, 1909) to enable virtual platform, run:
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart
You should now restart your computer to keep all installation clean.
Step 3) Update Kernel component
Download Linux kernel update package and double click on the downloaded file to update the kernel components. Once completed move to next step to set wsl 2 as default.
Step 4) Set WSL 2 as default version
To set WSL 2 as the default version of WSL, run the following command on PowerShell as administrator.
wsl --set-default-version 2
If you get an error showing "WSL 2 requires an update to its kernel component", make sure you followed step 3.
Step 5) Install Ubuntu on Windows 10
We will install Ubuntu 18.04
Step 6) Run Ubuntu on Windows 10
Now that your download is finished, you can run your Linux subsystem by clicking the launch button in the Windows Store or through the Windows start menu. A new terminal will be launched prompting to provide a username and password for your new system
Now all set ready to use your Ubuntu commands.
Now you have a working Ubuntu on Windows 10 WSL. For a better experience, you should try the Windows terminal which is a fast and powerful terminal app.
Let me know your feedback on this article in the below comment section.