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.
Table of Contents
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:
Feature | WSL1 | WSL2 |
---|---|---|
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 | ✅ | ❌ |
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:
-
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
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
-
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
-
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]
You can use this cmdlet to install multiple different Linux distros simultaneously.
-
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.
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:
- Enable “Windows Subsystem for Linux” and “Virtual Machine Platform.”
- Update the Linux kernel package to WSL2.
- Set WSL 2 to the default WSL version.
- Install Linux distros.
- Convert existing Linux distros to version 2.
- Confirm installed distros and their versions.
Let us now begin.
Enable Windows Features
-
Open the Optional Features window by typing in optionalfeatures in the Run Command box.
-
Here, check the boxes next to “Windows Subsystem for Linux” and “Virtual Machine Platform,” and then click Ok.
-
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
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:
-
Download the Linux kernel update package for your computer by clicking on the respective link below:
-
Once downloaded, run the .MSI file.
-
You will now see the installation wizard. On the first screen, click Next.
The upgrade process will now commence.
-
When it completes, click Finish.
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
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:
-
Start by opening the Microsoft Store page in any web browser for Linux distro by clicking on the respective link below:
-
On this page, click Get in Store app.
-
If asked for permission to open Microsoft Store, click Open Microsoft Store.
-
The Store app will now run with the respective distro page displaying. Click Get to begin the installation.
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.
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
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.
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
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
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.
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]
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]
From Settings App
Alternatively, you can also remove a distro from the Settings app in Windows 11 and Windows 10. Here is how:
-
Navigate to the installed apps page.
-
In Windows 11:
Settings app >> Apps >> Installed apps
-
In Windows 10:
Settings app >> Apps >> Apps & features
-
-
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.
-
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
-
Navigate to the installed apps page.
-
In Windows 11:
Settings app >> Apps >> Installed apps
-
In Windows 10:
Settings app >> Apps >> Apps & features
-
-
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.
-
When asked for confirmation, click Uninstall again.
From Optional Features
Alternatively, you can also remove WSL2 using the Optional Features window.
-
Open the Optional Features window by typing in optionalfeatures in the Run Command box.
-
Here, uncheck the boxes next to “Virtual Machine Platform” and “Windows Subsystem for Linux,” and then click Ok.
-
WSL2 will now be disabled. If asked, restart the 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.