How to Install WSL on Windows 10?

Microsoft introduced WSL (Windows Subsystem for Linux) in 2017, which provided the users to run different Linux Commands and other tools in a command-line interface on a Windows PC (without using HyperV or dual boot).

In 2019, Microsoft announced the release of a new version of WSL, and it was named WSL 2. This new version of WSL supports running graphical Linux apps on a Windows PC and utilizes a fully-operational Linux kernel with better file I/O performance and faster system calls. Another excellent achievement in WSL 2 as it is supported on the Home version of Windows 10, whereas, WSL only supported Windows 10 Pro.

How to Install WSL on Windows 10

Requirements to Enable the WSL Feature

A user’s PC must meet the following requirements to enable the WSL feature:

  • Support Hyper V
  • 64-bit version of Windows
  • Windows 10 version 1903 or higher. In the case of an ARM machine, Windows 10 version 2004 or higher. Windows 11 natively supports WSL 2.

If your PC does not meet these requirements, then you may have to use WSL 1 version only and you may follow the guidelines below but skip the parts related to WSL 2 (like setting the default version to WSL 2). 

If your PC meets the system requirements of WSL 2, you may follow the guidelines discussed below:

Install the WSL Through PowerShell

Microsoft has made it easier for its users to use a single PowerShell command to install the WSL feature along with the default Ubuntu installation (that can be changed). This PowerShell command will enable the required WSL component, download and install the latest Linux kernel, set WSL2 as the default, and install Ubuntu. So, follow the steps below to set up WSL with a single command (this command is supported only on Windows 10 2004 or above):

  1. Right-click Windows and select PowerShell (Admin).
  2. Now execute the following:
    wsl --install
    Install WSL Through the PowerShell
  3. Wait till the installation process of all the components is complete and then reboot your PC.
  4. Upon reboot, you may set up the Ubuntu distribution as per your requirements (discussed later) and you are ready to explore the wonders of Linux.

You may use the Ubuntu app in the Windows Start menu or use the Windows Terminal app to explore different Ubuntu features.

Install a non-Default Linux Distro Through the PowerShell Command

What if a user wants to install a different distribution than the default Ubuntu? So, don’t worry, here is a simple process:

  1. Open the Windows PowerShell (Admin) and execute the following to check the list of available Linux distros for WSL:
    wsl --list --online

    or

    wsl -l -o
    List the Online Linux Distros in WSL
  2. Now, check the list of available Linux distros and find which one fulfills your requirements. Usually, the following may be shown as available:
    Ubuntu
    
    Debian
    
    kali-linux
    
    opensuse-42
    
    SLES-12
  3. Then, execute the following command to install the required Linux distro (make sure to replace the <Distribution Name> with the distro name:
    wsl --install -d <Distribution Name>

    For example, to install Debian, you may use the command:

    wsl --install -d Debian
    Check Available Linux Distros and Install a Non-Default Linux Distros
  4. Now, wait till the installation is complete and restart your system.

Upon restart, set up the Linux distro as per your requirements (as discussed later). 

Install a Custom Linux Distro

There can be users who may need to use a Linux distro that is not available in the Microsoft Store and those users may use the official Microsoft reference page to import any Linux distribution to use with WSL as discussing it here is not in this article’s scope.

Install Multiple Linux Distros in WSL

If a user wants to use multiple Linux distros, he can do the same by using the (already discussed) following command in the PowerShell (do not forget to replace the <Distribution Name> with the distro name e.g., Debian)

wsl --install -d <Distribution Name>

In case multiple distros are installed, a user may check installed WSL distros in WSL by executing any one of the following in the PowerShell (Admin):

wsl -l -v

or

wsl --list --all
List All Linux Distros in WSL

Keep in mind that if you are trying to execute the WSL command in the bash, then make sure to enter .exe at the end of WSL, for example, to install a Linux distribution from within the bash, execute the following:

wsl.exe --install -d <Distribution Name>

Install WSL on a Server

If you are installing WSL on a server machine, then you can reference the Official Microsoft Windows Server Installation Guide of WSL.

Installing WSL in a VM-Based Windows

If a user is installing the WSL feature in a VM-based Windows, then he may execute the following in the host’s PowerShell (Admin) to expose the virtualization flags of the host to the VM:

Set-VMProcessor -VMName MyWSL -ExposeVirtualizationExtensions $true

Confirm the Installation of Linux Distribution and WSL Version

Now, to confirm if the Linux distributions are successfully installed and the WSL version is set to WSL 2, a user may execute the following (one by one) in the PowerShell (Admin):

wsl.exe --list --all

wsl --list --verbose
Check WSL Version of the Installed Linux Distros

Use the GUI Method to Install WSL

Many Windows users do not prefer a command-line method to install applications/utilities. Also, WSL version 1 cannot be installed by using the single PowerShell Command discussed earlier. Moreover, the users with Windows 10 version 1903 and 1909 cannot use the WSL install method. So, here is a more GUI-based method to use WSL on a Windows PC. 

Enable the WSL Feature on Windows 10

  1. Click Windows, search and open Turn Windows Features on or off.
    Open ‘Turn Windows Features on or off
  2. Now enable the following two by check-marking the related checkboxes:
    Virtual Machine Platform
    
    Windows Subsystem for Linux
    Enable Virtual Machine Platform and Windows Subsystem for Linux
  3. Then click on the OK button and let the system download/install the related files (make sure an Internet connection is available).
  4. Once done, restart your system.

The Windows Subsystem for Linux (WSL) can also be enabled by executing the following in the PowerShell (Admin):

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Enable Windows Subsystem for Linux Through the PowerShell

The Virtual Machine Platform can be enabled by executing the following in the PowerShell (Admin)

For Windows Version 2004 or higher:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Enable Virtual Machine Platform Through the PowerShell

For Windows Version 1903 and 1909:

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

Download and Install the Latest Kernel Update of WSL

After enabling the required features, a user must update the WSL kernel. 

  1. Download the latest WSL kernel update from Microsoft. The users with the ARM64 machines may download the ARM64 WSL Package.
  2. Once downloaded, right-click on the downloaded file, select Run as Administrator, and follow the prompts to update the WSL kernel.
    Update WSL

Set the Default Version of WSL to WSL 2

After updating the WSL kernel, a user must set the default WSL version to 2. But before that, check which version of WSL is set as default by executing the following in the PowerShell (Admin):

wsl -l -v

If WSL 2 is not the default, then open the PowerShell (Admin) and execute the following:

wsl --set-default-version 2
Set the Default WSL Version to WSL 2

This will change the WSL for all new installations of Linux distros to WSL 2. If a user has already installed a distro with WSL, he may execute the following (make sure to replace the <DistributionName> with the distro name) to change its WSL version to 2:

wsl --set-version <DistributionName> 2

For example:

wsl --set-version Ubuntu 2
Set the WSL Version of Ubuntu to WSL 2

Install a Linux Distro from the Microsoft Store

After setting up the default WSL version to 2, a user must install a Linux distro.

  1. Click Windows, search, and open Microsoft Store.
  2. Now search for the preferred Linux distribution. The following is the list of available Linux distros:
    Ubuntu 
    
    openSUSE Leap 15.1
    
    SUSE Linux Enterprise Server 12 SP5
    
    Kali Linux
    
    Debian GNU/Linux
    
    Fedora Remix for WSL
    
    Pengwin
    
    Pengwin Enterprise
    
    Alpine WSL
    
    Raft (Free Trial)
  3. Once selected, open the desired Linux distro and click on Get.
  4. Then click on Install and let the distro install (e.g., Ubuntu).
  5. Afterward, restart your system and configure the distro as discussed in the next step. 
    Install Ubuntu Through the Microsoft Store

Configure the Linux Distro After the Install

  1. Once the Linux distribution is installed, launch it (either from the Start menu or from a command-line tool) and a Command Prompt window will be shown. 
  2. Now, enter a user name (in lowercase) for the Ubuntu (this can be different from the Windows credentials).
  3. Then enter a password for the Ubuntu account and afterward, confirm the password.
    Enter Username and Password for the Linux Distro in WSL
  4. Now use the different Linux commands as per your requirements.
  5. To exit the Ubuntu bash, execute Exit in the bash.

Methods to Open a Linux Distro in WSL

There are several methods to open an installed Linux distro in Windows:

  1. You can type the Linux distro name in the Windows Start menu and launch it from there.
    Open Ubuntu Through the Windows Start Menu
  2. From the Windows Command Prompt or PowerShell after typing the distro name (like Ubuntu) and hitting Enter.
  3. Execute WSL.exe in the Command Prompt or PowerShell to open the Linux terminal in the current shell or use wsl [command] to execute the WSL command. In the case of multiple distros, a user can configure the default distro by executing the following:
    wsl -s <DistributionName>

    For example

    wsl -s Debian
  4. To open a specific WSL distro, a user may execute the following in the PowerShell (Admin):
    wsl -d <DistributionName>
  5. Last but not least and our favorite: Windows Terminal.

Install the Windows Terminal

Windows Terminal is a Microsoft terminal emulator that supports multiple tabs and is a replacement for Windows console. The usage of WSL becomes very easy with the Windows Terminal. To Install Windows Terminal:

  1. Open the Microsoft Store and search for Windows Terminal.
  2. Now click on Get and then click on Install.
  3. Once installed, launch it and use it to execute the WSL commands.
    Install the Windows Terminal App

Update the Linux Distros and Kernel to the Latest Build

After configuring the Linux distribution, the first step should be to update it as Microsoft does not auto-update these distros. To do so, execute the following in the Linux bash:

sudo apt update && sudo apt upgrade
Run the Sudo Apt Update Command in WSL Linux

To update the WSL kernel, execute the following in the PowerShell (Admin):

wsl –update
Run the WSL Update Command

To check the general status of the WSL, execute the following in the PowerShell (Admin):

wsl --status

Install Common Linux Packages

Once the distro is updated, a user may want to install different Linux packages in WSL.  A user may use the APT package repository and execute the following in the bash (e.g., to install htop):

$ sudo apt install htop
Install the htop Package in WSL Linux

And htop can be launched by executing the following in the bash:

$ htop

To install GUI Win-Kex for Kali-Linux, a user may execute the following (one by one) in the bash:

sudo apt update

sudo apt install -y kali-win-kex

Once installed, you may run Win-Kex in different options. The details can be found in the Official Kali documentation.

WSL and Windows File System

Where are the Linux files located in Windows? A natural question comes to a user’s mind. WSL has its File System installed on the following location (do not change or delete files in the  directory):

%LOCALAPPDATA%\Lxss\

During usage, a user may have to access the host’s file system in WSL. To do so, execute the following in the bash:

/mnt/c/
Access the Host’s File System in WSL Linux

Enable the WSL1 Feature

There can be times where a user requires to install WSL1 (not WSL2) and to do so, simply follow the above steps, just skip WSL parts. To change the default WSL, a user may execute the following in the PowerShell (Admin):

wsl --set-default-version 1

Afterward, the user may install a new Linux distro to fulfill his requirements (as discussed earlier). 

If the WSL version cannot be changed to 1, execute the following in the PowerShell (Admin):

New-ItemProperty HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss DefaultVersion -Value 1 -Force

Then, reboot your system and upon reboot, disable the Virtual Machine Platform. Afterward, your system is configured to use WSL 1.

Remove WSL and Linux Distro from the System

If you are done with WSL and want to remove it from the system, a simple process to do it is:

  1. Right-click on Windows and open Apps & Features.
  2. Now expand the Linux distro (e.g., Ubuntu) and click on Uninstall.
    Uninstall Ubuntu in Apps & Settings
  3. Then, confirm to uninstall the distro and reboot your PC.
  4. Upon reboot, disable the Virtual Machine Platform and Windows Subsystem for Linux (as discussed earlier) in Turn Windows Features on or off.
    Disable Virtual Machine Platform and Windows Subsystem for Linux
  5. Now reboot your PC and upon reboot, the WSL is removed from the PC.

So, that’s it, we hope that this article has served its purpose and cleared the basic ideas of WSL. 

ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.