The latest version of the Windows Subsystem for Linux is a significant upgrade, but also one that takes a few steps to set up.
Microsoft dropped plenty of jaws when it launched the Windows Subsystem for Linux, a way to run actual Linux inside Windows 10 without the need to set up a virtual machine. The project has seen a ton of support, and WSL2 is the latest and greatest.
It takes things a little further and adds yet more awesomeness to the Linux experience on Windows 10. If you haven’t yet checked it out, here’s how to get started.
How to enable Windows Subsystem for Linux
Before you can get WSL2, you need to have WSL. That may sound slightly strange, but the methods of enabling the first iteration and the second are quite different. But to have the newest version, you first need to have the first. There’s no direct path to just installing WSL2.
We have a full guide on getting set up with the Windows Subsystem for Linux, which you should check out for a full primer on getting started, but if you’re looking for the quickest route, there’s a single line of code to enable it on your machine.
Open PowerShell as administrator and enter this command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Eventually, you will need to reboot your PC, but you can leave it until later if you’re going straight to installing WSL2.
How to install WSL2 on Windows 10
Now you have the Windows Subsystem for Linux enabled. It’s time to download and install WSL2. The latest iteration is essentially a tiny virtual machine that boots up in seconds and has a proper Linux kernel at its core. And that’s why the installation differs a little from enabling regular old WSL.
There are also a couple of pre-requisites for using WSL2 on Windows 10. You need to be on the following versions:
- For x64 systems: Version 1903 or higher, with Build 18362 or higher.
- For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.
If you have anything lower, you’ll need to run Windows Update before going any further.
Assuming that’s all good, the rest is straightforward.
Enabling Virtual Machine
If you don’t already have this enabled, you’ll need to turn it on before installing WSL2. As already stated, WSL2 is a tiny virtual machine, so Windows 10 needs to be prepared for that. If you have this enabled already, skip and go straight to rebooting your PC to make sure you’re ready to install.
The quickest way to do it is in PowerShell. Open PowerShell as administrator and enter this command:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Now reboot your PC and move to the next section.
Downloading and installing WSL2
The next part takes only a couple of steps.
- Download the WSL2 Kernel update.
- Run the installer.
- When prompted for elevated permissions, click yes.
Once the installer has done its thing, you’ll now have WSL2 successfully installed on your PC.
Setting WSL2 for your Linux distros
The good thing about WSL2 is that it doesn’t replace WSL. It just runs alongside it. This means you can run Linux installs with a combination of different versions. You’re able to set either as default as well as setting a version specifically to each Linux distro you have on your PC.
Let’s break down some of the key commands to use in PowerShell that you’ll need to know.
Setting WSL2 as default
If you want everything to run on WSL2 as soon as you install it, you can set it as the default version.
wsl --set-default-version 2
Listing installed Linux distros and their WSL version
With WSL2 set as default, any Linux installs after that will use it automatically. You can easily check which version of WSL your installed Linux distros are using.
wsl --list --verbose
Using the verbose flag will give you the breakdown of which version of WSL is attached to which Linux installation. Without it, you’ll simply get a list of the versions of Linux you have installed.
Changing the version of WSL per Linux installation
While setting WSL2 as default will apply it to anything you install afterward. If you’re already set up, you’ll need to manually convert. Likewise, if you wish to go between versions 1 and 2 or run a mixture on your system, you can do that.
wsl --set-version <distribution name> <versionNumber>
So, as an example, if you have a Debian installation on WSL that you need to convert to WSL2, you’d enter
wsl --set-version debian 2.
Launch specific Linux installations in PowerShell
If you only have one version of Linux installed, simply typing
wsl in PowerShell will launch you into the associated bash shell. But if you have multiple, you can launch a specific distro with this command.
wsl -d <distribution name>
Once you’re done, typing
exit will take you back into PowerShell.
From here on out, you’re ready to go forth and install all the Linux you want. Our full guide will help you along the way, but once WSL2 is set up how you like it, it just fades into the background.
It’s also worth grabbing the Windows Terminal app from the Microsoft Store if you’re using WSL. While you can just use the standard terminal installed with each or launch through PowerShell as shown above, Windows Terminal has a neat tabbed interface that lets you run multiple shells at once. Have PowerShell, Linux, Azure Cloud Shell, even Command Prompt, all open together side-by-side in one window.
Microsoft’s new modern, open-source terminal application.
Whether you’re into theming or just want to run a bunch of different shells side-by-side, the Windows Terminal application can do it all.