If you want to try out the improved Windows Subsystem for Linux 2 (aka WSL 2) in the latest Windows versions here’s how — I cover everything you need to do to install it, in this post.
WSL 2 is a big upgrade to the original WSL Microsoft introduced in 2017. More than a simple version bump, WSL 2 is faster, more versatile, and uses a real Linux kernel for the first time.
Plus, new Linux kernel updates will be released as Windows 10 software updates — which is kinda crazy when you think about it!
Improved performance was Microsoft’s motivation for created the souped-up WSL2. And it figured the best way to do that was to add full system call compatibility, i.e. put a real Linux kernel right at the heart of things.
“[This] new architecture presents a better platform for the WSL team to deliver features that make WSL an amazing way to run a Linux environment in Windows,” say Microsoft of the tech.
The crazy shows no sign of abating either as Microsoft plans to let users run desktop Linux apps on Windows 10 and leverage GPU-intensive tasks.
And the best news is that it is much easier to install WSL on Windows 10, as this updated guide shows.
Install WSL 2 on Windows 10
To install WSL 2 on Windows 10 you need the minimum:
- Windows 10 May 2020 (2004), Windows 10 May 2019 (1903), or Windows 10 November 2019 (1909)
- A computer with Hyper-V Virtualization support
I’d be mighty surprised if anyone who’s reading this guide doesn’t meet those requirements but, if you don’t you can use WSL 1 rather than WSL 2.
What’s awesome is that if you use Windows 10 May 2020 (2004) update or later you can install WSL2 with a single command, or a single click — no hassle.
Installing WSL 2 on OS Build 2004 (or later)
To install WSL 2 on Windows 10 OS Build 2004 or later you can open a command prompt (with Administrator permissions) and type in the following command:
As soon as you hit
enter the process gets to work enabling WSL, any optional features required, fetches the latest WSL Linux kernel version, and installs Ubuntu as the default distro:
Once done, reboot your computer. Log in to Windows 10 and the command prompt will open again. This time you’ll be walked through setting up Ubuntu with a username and password (these don’t need to be the same as your Windows username and password).
Once done you can you can launch the ‘Ubuntu’ app from the Start Menu to get started, or install the Microsoft Terminal app to start exploring your newly-installed Ubuntu install — don’t forget to run an
apt update && apt upgrade though — this is a REAL Ubuntu system, after all!
Install WSL 2 (Old Method)
If you use an older version of Windows 10 you can still install WSL 2 (Microsoft backported WSL 2 to older versions of Windows 10 in Windows Update KB4566116) but the process isn’t as simple as in the 2004 update.
To install WSL 2 on Windows 10 (OS Build 1909 or 1903) you need to follow 4 steps:
- Enable WSL 2
- Enable ‘Virtual Machine Platform’
- Set WSL 2 as default
- Install a Linux distro
I walk through each step in turn below. I recommend using the PowerShell app, which you need to run as an administrator. You can find PowerShell in the Windows Start Menu.
Note: it is possible to install WSL 1 using a GUI too but it’s much faster to use the command line, and since WSL is a CLI tool it kinda makes sense too!
Step 1. Enable WSL
Regardless of which version of WSL you want to use you first need to enable it. To do this open the PowerShell tool as an Administrator and run the command below. Be careful not to mistype or leave out any character in the command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Only want to use WSL 1? You can skip to step 4.
Step 2. Enable ‘Virtual Machine Platform’
WSL 2 requires Windows 10’s “Virtual Machine Platform” feature to be enabled. This is separate from Hyper-V and hands some of the more interesting platform integrations available in the new version of the Windows Subsystem for Linux.
To enable Virtual Machine Platform on Windows 10 (2004) open PowerShell as Administrator and run:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
To enable Virtual Machine Platform on Windows 10 (1903, 1909) open PowerShell as Administrator and run:
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart
To ensure all of the relevant bits and pieces fall neatly in to place you should restart your system at this point or you may find that things don’t work as intended.
Step 3. Set WSL 2 as default
Open PowerShell as Administrator and run this command to set WSL 2 as the default version of WSL:
wsl --set-default-version 2
You can (at any time) configure a distro to run in WSL 1 mode if you need to.
Step 4. Install a distro
With WSL and the necessary virtualisation tech all in place all that is left for you to do is pick and install a Linux distro from the Microsoft Store.
Several different distros are available, including OpenSUSE, Pengwin, Fedora Remix, and Alpine Linux. But my personal recommendation is (naturally) Ubuntu 20.04 LTS (though 18.04 LTS and 16.04 LTS are also available).
To install Ubuntu on Windows 10 open the Microsoft Store app, search for “Ubuntu 20.04”, and hit the “Get” button:
Whilst you in the Microsoft Store I highly recommend that you also install the open source Windows Terminal app. This tool is designed to give you the best possible WSL experience:
5. Use WSL 2
When you installed Ubuntu (or a different Linux distro) a shortcut was added to the Start Menu. Use this to “open” Ubuntu (or whichever distro you chose). The first time you run the distro things will seem a little slow. This is expected; the distro has to unpack and decompress all of its contents — just don’t interrupt the process.
You will also be promoted to set a username and password for use on the distro. Try to pick something you won’t forget.
Convert Ubuntu on WSL 1 to WSL 2
If you use WSL 1 you can upgrade an existing WSL 1 installation to WSL 2. To convert an existing WSL 1 distro to WSL 2 run the following in PowerShell, e..g,:
wsl.exe --set-version Ubuntu 2
You should replace ‘Ubuntu’ with the name of whichever distro your WSL 1 install runs.