Skip to content

Installing WSL 2

The Windows Subsystem for Linux (WSL) will let you run a Linux environment directly on Windows 10. It is an unmodified OS, but highly integrated into Windows and without the overhead of a virtual machine.

Requirements

  1. Windows version: WSL2 is compatible with the Home, Pro, or Server editions of Windows.
    For x64 systems: Version 1903 or higher, with Build 18362 or higher.
    For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.

To check your version and build number, open Settings -> System -> About. Scroll Down to check Windows Specifications.

  1. Hyper-V Virtualization: Search for System Information. Scroll down and see if Hyper-V Virtualization has a Yes next to it or not. If it is enabled, move on to the steps to install WSL 2.

    If Hyper-V virtualization is not enabled check the other three items starting with Hyper-V. If they have a Yes next to it, you can enable Hyper-V Virtualization. If not, you can't run Hyper-V on your system.


To enable Hyper-V you have to go into your BIOS (or UEFI firmware) settings and turn on support for virtualization. To do this, restart your machine and press F10(it depends on your machine) to open BIOS settings. Enable Virtualization Technology and then Save and Exit.

Steps

  1. Enable WSL

    Open Windows Powershell as administrator and run the following command

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

  2. Enable Virtual Machine Feature

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

  3. Set WSL2 as default version

    wsl --set-default-version 2
    
    If the command gives an output as shown in the following image, you have to download the linux kernel update package. If it does not give any error proceed to the next step.

Download the linux kernel update package from here: WSL2 Linux kernel update for x64 machines
After the installation, double-click to run and select 'yes' to approve the installation.

  1. Install distro of choice

    Open Microsoft Store and search for Linux distribution of your choice. You can choose Ubuntu(16.04 LTS, 18.04 LTS, 20.04 LTS), Debian, Kali, SUSE etc. Preferable choice would be Ubuntu 18.04LTS or Ubuntu 20.04LTS.

    Just click on 'Get' to begin the installation.


Launch the app after installation is complete. Create a username and password for your distro.

  1. To check for the WSL version

    Run the following in powershell

    wsl -l -v
    
    This should give the following result:


    To change WSL version between 1 and 2:
    wsl --set-version <DistributionName> <WSLversion>
    

  2. Start working

    Open powershell and type wsl.


Now you are ready to work.

It is very easy for you to access files in Linux from Windows and vice versa. All your files are stored in C:\Users\<yourname>\ path. So just create new directories accordingly.

Happy Hacking!