How To Install Windows Subsystem For Linux 2 (WSL2) On Windows 11/10

WSL2 Windows 11 10WSL2 Windows 11 10

The Windows operating system allows you to run a lightweight Linux distribution on top of itself. This feature is known as “Windows Subsystem for Linux,” or WSL. It has 2 versions: WSL1 (WSL) and WSL2. The latter is an improved version of the simpler WSL, but the legacy WSL has the advantage of better performance across the OS file system.

In this guide, we are going to show you how to install WSL2 on Windows 11 and Windows 10, and briefly discuss how it is better than WSL1. By the end of this post, you will be able to download, install, and run multiple Linux distributions on top of the Windows OS.

WSL1 VS WSL2

The Windows Subsystem for Linux version 2 superseded WSL1 because of its enhancements in certain areas of performance. However, some people still prefer using WSL1 for their testing and deployment purposes.

The table below briefly highlights the features of both versions:

FeatureWSL1WSL2
Integration between Windows and Linux
Fast boot times
Small resource footprint compared to traditional Virtual Machines
Runs with current versions of VMware and VirtualBox
Managed VM
Full Linux Kernel
Full system call compatibility
Performance across OS file systems
WSL1 VS WSL2. Source: Microsoft

With that, let us show you how to install WSL2 on your Windows PC.

Install WSL2 on Windows 11/10

Before we proceed to install WSL2, we must first confirm your OS version. If you are using Windows 11, or Windows 10 2004 or newer, then you can install WSL 2 using the regular method. However, if you are using Windows 10 version 1909 or older, then you must perform a manual WSL2 installation for which the method is given in the next section.

Check your Windows version by typing in winver in the Run Command box.

You must also have virtualization enabled on your computer. Check if your computer supports virtualization and then enable virtualization from the system BIOS. Once that is done, you may now proceed to install WSL2

Install WSL2 on Windows 11 and Windows 10 2004 or Newer

Follow these steps to install and run WSL2 on your Windows 11 or Windows 10 version 2004 (or newer) computers:

  1. First, we must check the available Linux distributions that can be installed on your computer. For that, open an elevated Command Prompt and run the following cmdlet:

    wsl --list --online
    List of available Linux distros
    List of available Linux distros

    As you can see in the image above, there is an asterisk before “Ubuntu,” which signifies that Ubuntu is the default distro installed when a distro isn’t specified.

    At the time of writing this post, the following distros were available:

    • Ubuntu
    • Debian
    • Kali-Linux
    • SLES-12
    • SLES-15
    • Ubuntu 18.04 LTS
    • Ubuntu 20.04 LTS
    • Oracle Linux 8.5
    • Oracle Linux 7.9
  2. Now, run the following cmdlet to install the default distro with WSL2:

    Note: If you are installing WSL2/Linux distro for the first time, the process might take longer, as Windows initially installed WSL2 and then the distro. Once WSL2 has been installed, you can then continue to install multiple Linux distros using Step 3 given below.

    wsl --install
    Install default WSL distro
    Install default WSL distro
  3. If you wish to install a specific distro, you can use the -d switch to specify it in the following cmdlet. Replace [DistributionName] with the name of the Linux distro you want to install (as seen in the first step above):

    wsl --install -d [DistributionName]
    Install specific WSL distro
    Install specific WSL distro

    You can use this cmdlet to install multiple different Linux distros simultaneously.

  4. When the Linux distros are installed, restart your computer for the changes to take effect.

When the computer reboots, you may see command-line windows to further configure the Linux distros. Enter the username and password for the user account on the distro(s) and continue as you may like.

Configure username and password
Configure username and password

Install WSL2 on Windows 10 1909 or Older

If you are on Windows 10 version 1909 or older, then you will need to install WSL2 manually, but it can be done. You will need to perform the following processes in the given order:

  1. Enable “Windows Subsystem for Linux” and “Virtual Machine Platform.”
  2. Update the Linux kernel package to WSL2.
  3. Set WSL 2 to the default WSL version.
  4. Install Linux distros.
  5. Convert existing Linux distros to version 2.
  6. Confirm installed distros and their versions.

Let us now begin.

Enable Windows Features

  1. Open the Optional Features window by typing in optionalfeatures in the Run Command box.

    optionalfeatures
    Open Optional Features window
  2. Here, check the boxes next to “Windows Subsystem for Linux” and “Virtual Machine Platform,” and then click Ok.

    Enable features from Optional Features
    Enable features from Optional Features
  3. The features will now install. When the installation completes, restart the computer for the changes to take effect.

Alternatively, you can also enable both of these Windows features using Windows PowerShell. Simply run the following cmdlets in an elevated PowerShell instance one after the other:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Enable features using PowerShell
Enable features using PowerShell

Doing so will install WSL1. However, to upgrade to WSL2, you must install the kernel update package.

Update the Linux Kernel Package

Follow these steps to update the Linux kernel package:

  1. Download the Linux kernel update package for your computer by clicking on the respective link below:

    WSL2 Linux kernel update package for x64 machines

    WSL2 Linux kernel update package for ARM64 machines

  2. Once downloaded, run the .MSI file.

  3. You will now see the installation wizard. On the first screen, click Next.

    Linux kernel update package install next
    Proceed with Linux kernel update

    The upgrade process will now commence.

  4. When it completes, click Finish.

    Linux kernel update package install finish
    Close wizard

Make WSL2 the Default Version

Now that WSL2 has been installed, it is time to make it the default WSL version. For that, simply run the following cmdlet in an elevated PowerShell instance:

wsl --set-default-version 2
Set WSL2 as the default version
Set WSL2 as the default version

Now, it is time to install your preferred Linux distro(s).

You can also change the default WSL version by changing the integer from 2 to 1 in the command above.

Install Linux Distros

You must now install the Linux distribution(s) on top of WSL2. These can be installed from Microsoft Store. Here is how:

  1. Start by opening the Microsoft Store page in any web browser for Linux distro by clicking on the respective link below:

  2. On this page, click Get in Store app.

    Get Linux distro in Store
    Get Linux distro in Store
  3. If asked for permission to open Microsoft Store, click Open Microsoft Store.

    Open Store
    Open Store
  4. The Store app will now run with the respective distro page displaying. Click Get to begin the installation.

    Install Linux distro
    Install Linux distro

    The Linux distribution will now be installed and ready to function.

The first time you launch the distribution, a console window will open and ask you to wait for a minute or two for files to de-compress and be stored on your PC. Wait for the window to close. When the Linux window opens, you’ll be asked to create a user account and enter the account name and set a password. Do the need full and you are good to use the distro.

Configure username and password
Configure username and password

Convert Existing Distro

This step is only required if you had previously installed a WSL1 Linux distribution. If you have just installed WSL2 using the given method above, you do not need to convert any distros to WSL2 as none would be installed on your computer at the moment.

That said, if any specific WSL1 distro is installed, you can simply convert it to WSL2 by running the following cmdlet in an elevated Command Prompt:

Replace [DistributionName] with the name of the distro.

wsl --set-version [DistributionName] 2
Change WSL distro version
Change WSL distro version

You can also change a distro from version 2 to 1 simply by changing the integer in the command above.

Check Installed WSL2 Distros and Versions

Finally, you need to check which distributions have been installed on your computer and what version they are (1 or 2). This can be done by running the following cmdlet:

wsl --list --verbose

Alternatively, you can also use the “wsl -l -v” cmdlet.

Check WSL installed and default distro
Check WSL installed and default distro

If you find that one or more distros are not the right version, you can convert them using the given method above.

Moreover, if you have a distro installed that is no longer required, you can uninstall it using the given method below.

After having performed these steps, you should have functioning WSL2 distros installed on top of your Windows OS.

Once WSL2 and its distros have been installed, there are a few things a user will need to know for its maintenance. Like updating the kernel, changing the default distro, and even uninstalling it.

Update Linux Kernel

The kernel is responsible for translating the tasks and commands from the software to the hardware, and vice versa. Therefore, keeping the Linux kernel updates is essential for getting the best performance.

You can update your Linux kernel (if one is available) using this cmdlet in an elevated Command Prompt:

wsl --update
Update Linux kernel
Update Linux kernel

Change Default Distro

If you have more than one Linux distro installed, you can change it to any one of the installed distros. But before you do, we advise that you check which distros are currently installed and which one is the default one. To check that, run this cmdlet:

wsl --list --verbose
Check WSL installed and default distro2
Check WSL installed and default distro

The distro with the asterisk marks the default distro. To change it, run the following cmdlet while replacing [DistributionName] with the name of the distro you want to set as default:

wsl -s [DistributionName]

This will change the default Linux distro. To confirm, you can recheck the installed and default distro information, as in the image below.

Change WSL default distro
Change WSL default distro

Run Different WSL2 Distro without changing Default

The method given above will change your default Linux distro, and every time you run it, the selected distro would run automatically. However, you can also run a different distro without having to change the default distro.

To run a specific Linux distro on WSL2, simply use the following cmdlet while replacing [DistributionName] with the name of the distro that you want to run:

wsl -d [DistributionName]
Run specific WSL distro without changing default
Run specific WSL distro without changing default

Uninstall WSL2 Distro

From Command Prompt

If you wish to remove a Linux distro from your PC for whatever reason, you can use this cmdlet while replacing [DistributionName] with the name of the distro that you want to remove:

wsl --unregister [DistributionName]
Uninstall a Linux distro
Uninstall a Linux distro

From Settings App

Alternatively, you can also remove a distro from the Settings app in Windows 11 and Windows 10. Here is how:

  1. Navigate to the installed apps page.

    • In Windows 11:

      Settings app >> Apps >> Installed apps
    • In Windows 10:

      Settings app >> Apps >> Apps & features
  2. Here, search for the distribution name you want to remove, click on it to expand more options, and then click Uninstall. If you see ellipses (3 dots) in front of the distro name, then click those to expand more options.

    Uninstall distro from Settings app
    Uninstall distro from Settings app
  3. When asked for confirmation, click Uninstall again.

Uninstall WSL2 from Windows

If you feel like removing Windows Subsystem for Linux from your PC entirely, you can do so from the Settings app as well the Optional Features window.

From Settings App

  1. Navigate to the installed apps page.

    • In Windows 11:

      Settings app >> Apps >> Installed apps
    • In Windows 10:

      Settings app >> Apps >> Apps & features
  2. Here, search for “Windows Subsystem for Linux,” click on it to expand more options, and then click Uninstall. If you see ellipses (3 dots) in front of the distro name, then click those to expand more options.

    Uninstall WSL2 from Settings app
    Uninstall WSL2 from Settings app
  3. When asked for confirmation, click Uninstall again.

From Optional Features

Alternatively, you can also remove WSL2 using the Optional Features window.

  1. Open the Optional Features window by typing in optionalfeatures in the Run Command box.

    optionalfeatures
    Open Optional Features
  2. Here, uncheck the boxes next to “Virtual Machine Platform” and “Windows Subsystem for Linux,” and then click Ok.

    Disable optional features
    Disable optional features
  3. WSL2 will now be disabled. If asked, restart the computer.

    Restart computer
    Restart computer

Note that disabling “Windows Subsystem for Linux” and “Virtual Machine Platform” alone will not eliminate the distros from your PC, and only removing the distros will not disable WSL2 from your computer.

Closing Thoughts

Windows Subsystem for Linux 2 is an excellent feature to have if you are a Windows user but need to perform the occasional Linux tasks. Although the Linux operating system offers more control and features since it is based on the Command Line Interface (CLI), some people prefer using the Windows operating system as it is more user-friendly.

That said, WSL is the best option to get the best of both worlds.

If you liked this post, Share it on:
Subhan Zafar is an established IT professional with interests in Windows and Server infrastructure testing and research, and is currently working with Itechtics as a research consultant. He has studied Electrical Engineering and is also certified by Huawei (HCNA & HCNP Routing and Switching).

Get Updates in Your Inbox

Sign up for the regular updates and be the first to know about the latest tech information

Talk to us now

Talk to us straight and get your questions answered right away

Tell Us About Your Project