WSL stands short for “Windows Subsystem for Linux”. It allows you to run a Linux environment directly on Windows, where you can use all command-line tools you know from Linux. In this step-by-step guide, I want to show you how you can set up a Linux environment on Windows 10.
Since mid-2020, the new WSL version 2 is available, which represents a fundamental revision of the underlying architecture and enables better performance and speed.
Table of Contents
- Enable WSL
- Check if virtualization is enabled
- Enable Virtual Machine feature
- Restart machine
- Download the Linux kernel update package
- Set WSL 2 as default version
- Install a Linux distribution
- (Optional) Check WSL version assigned to Linux distributions
Prerequisites for WSL 2
You can check your OS Build and System Type by going to Settings > System > About
- Windows 10 Pro
- Have a x64 or ARM64 machine
- 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 everything set up for WSL 2 (Virtual Machine feature enabled and Linux kernel update) and already a Linux distribution installed with WSL 1, you can go to step 8, where I show you how you can change the assigned version.
Enabling WSL 2
Before running WSL 2 we have to enable WSL 1 first (if you already have set up WSL 1 you can go to step 2).
1. Enable WSL
Open your PowerShell as an Administrator and run this command (you can find this command here in the official docs):
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
2. Check if virtualization is enabled
To enable the virtual machine feature (in step 3), your machine will require virtualization capabilities. You can check this in your Task Manager. In your CPU overview you can see if virtualization is enabled.
If it is not enabled, you have to change your settings in the BIOS. You can easily start into your BIOS with the Advanced Startup feature (if you already have it enabled, you can skip here and go to step 3).
Go to Settings > Update & Security > Recovery and click Restart now under Advanced Startup. Windows will now restart into a recovery environment.
When being in recovery, you have to click Troubleshoot and then Advanced Options. The third screen you see will look like this:
Select UEFI Firmware Settings and your machine will boot into the BIOS. The BIOS looks different depending on your motherboard manufacturer.
You can check where to find the CPU settings by looking on your manufacturer’s homepage (common manufacturers are Asus, MSI, ASRock, Intel, …). You can get information about your motherboard by running this command in PowerShell:
wmic baseboard get product,Manufacturer,version,serialnumber
The CPU settings can probably be found under Processor, Chipset or Northbridge.
The setting to enable virtualization may be called VT-x, AMD-V, SVM, or Vanderpool. Enable Intel VT-d or AMD IOMMU if the options are available.
After enabling virtualization, you can save and reboot.
3. Enable Virtual Machine feature
Before installing WSL 2 you have to enable this feature. Open PowerShell as Administrator and run (this command can be found here in the official docs):
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
4. Restart machine
After running both commands, you have to restart your machine to complete the WSL install and update to WSL 2.
5. Download the Linux kernel update package
If you don’t know which architecture you have, you can check it in your settings (see instruction above under “Prerequisites for WSL 2”).
After downloading it, don’t forget to install it 😄
6. Set WSL 2 as default version
Open PowerShell and run this command:
wsl --set-default-version 2
7. Install a Linux distribution
You can search for a Linux distribution in the Microsoft Store. You can also install more than one distro and switch between them.
I would recommend installing Ubuntu, as the publisher Canonical worked together with Microsoft to develop WSL.
When you first start Ubuntu, you will be asked to create a user and a password. If you want, you can just type in the credentials you already use on your Windows login.
Now you have everything set up and installed 🎉
8. (Optional) Check WSL version assigned to Linux distributions
With the command
wsl -l -v in the PowerShell you can list all your Linux distros and check the version. The output looks like this:
If you have everything set up for WSL 2 (Virtual Machine feature enabled and Linux kernel update) and a distro is still on version 1 you can easily update it with following command:
wsl --set-version <distribution name> <versionNumber>
So for example:
wsl --set-version Ubuntu 2
Windows then automatically updates the assigned WSL version.