How to Install WSL2 on Windows

WSL (Windows Subsystem for Linux) is a Windows 10 feature that allows users to run Linux applications natively on Windows.

It provides a compatibility layer between Linux and Windows, enabling developers to use Linux tools and workflows on a Windows machine. WSL2 is the latest version of WSL, which uses a real Linux kernel and provides faster performance and improved compatibility. With WSL2, users can seamlessly switch between Windows and Linux applications without the need for a separate virtual machine or dual-boot setup. Using WSL can improve productivity and streamline workflows for developers who need to work with both Windows and Linux environments.

Steps:

  1. First, make sure that your laptop is running Windows 10, version 2004 or higher, and that you have enabled the virtualization feature in your BIOS settings. You can check if virtualization is enabled by following these steps:
  • Restart your laptop and press the key to enter the BIOS setup (usually F2, F10, or Delete).
  • Look for an option called “Virtualization” or “VT-x” and make sure it is enabled.
  • Save your changes and exit the BIOS setup.
  1. Next, you need to enable the Windows Subsystem for Linux (WSL) feature on your laptop. Here’s how:
  • Open the Windows Start menu and search for “Turn Windows features on or off”.
  • In the list of features, find “Windows Subsystem for Linux” and check the box next to it.
  • Click OK and wait for the feature to be installed. You may be prompted to restart your laptop.
  1. After enabling WSL, you need to update to WSL2. Open PowerShell as an administrator and run the following command:

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

  1. Restart your laptop and download the WSL2 Linux kernel update package from the Microsoft website: https://aka.ms/wsl2kernel
  2. Install the downloaded package by double-clicking on it and following the prompts.
  3. Finally, set WSL2 as the default version by opening PowerShell as an administrator and running the following command:

wsl –set-default-version 2