install wsl 2 on windows 10 and install linux

The Windows Subsystem for Linux (WSL) makes it possible to run a Linux environment directly on Windows, i.e. no need for a virtual machine or dual-boot configuration. Or in other words, WSL brings a compatibility layer to run Linux binary executables.

WSL 2 is the latest implementation of this technology, and it features a full Linux kernel, with faster performance compared to WSL 1.

In this post, we look at the steps to install WSL 2 on Windows 10 and then run Ubuntu Linux.

Before we proceed, you need to check your Windows version to confirm that you are running Windows 10, Version 1903 (Build 18362 or higher). This is the minimum requirement to use WSL 2.

To quickly check your Windows version, proceed as follows.

  • Press the Windows logo key + R
  • In the Run window that appears, type winver in the text box
  • Click OK

If your computer does not meet the minimum requirements, you would need to update to the latest Windows version before you continue with the next steps.

Step 1: Enable WSL Feature

The first thing you would need to do is enable the Windows Subsystem for Linux feature. Simply launch Windows PowerShell as an administrator, and then run the following command.

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Step 2: Enable Virtual Machine Platform Feature

Next, you need to run the following command in Windows PowerShell (Admin) to enable the Virtual Machine Platform feature.

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

It is important to restart your computer after this step, so that the necessary system files and settings can be updated.

Step 3: Set WSL 2 as Default

Now, you would need to set WSL 2 as your default version. To do this, run the following command in Windows PowerShell.

wsl --set-default-version

If you see a message saying, "WSL 2 requires an update to its kernel component …," then you would first need to download and install the Linux kernel update package from Microsoft. The installation file is available at the official link below. https://aka.ms/wsl2kernel

Download and install the right package based on your system type -- i.e. X64 or ARM64.

You can check your system type by running the following command in PowerShell.

systeminfo | find "System Type"

Step 4: Install Ubuntu Linux

Several Linux distributions can be installed; however, this tutorial focuses on installing Ubuntu Linux. Open Microsoft Store and click Search in the upper right-hand corner, type Ubuntu and press enter. In the list of apps that appears, click the latest LTS version of Ubuntu – which is Ubuntu 20.04 LTS at the time of this post – and then click Get on the next page to start the installation process.

Install Ubuntu from Microsoft Store
Install Ubuntu from Microsoft Store

Optionally, you may also install Windows Terminal from Microsoft Store. This allows you to easily switch between multiple Linux command line interfaces by way of multiple tabs.

Step 5: Launch Ubuntu

In the Windows start menu, find and launch Ubuntu. After a few minutes of the system configuring itself for first-time use, you would be prompted to create a user account and password.

Ubuntu Setup username

We took multiple steps to get to this point. However, the experience is getting better. Ubuntu has confirmed in a blog post that it will be possible to get up and running with Ubuntu Linux on WSL with just one line of command as follows.

wsl.exe --install

Once executed, the above command will enable and install all the required components. As of the time of this post, this simplified process requires Windows 10 Insiders Preview (Build 20246.)

Uninstall WSL 2

Open PowerShell (Admin) and run the following commands one after the other to disable the WSL and Virtual Machine Platforms features respectively.

dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux
dism.exe /online /disable-feature /featurename:VirtualMachinePlatform

Uninstalling Ubuntu itself is as simple as right clicking the app tile and then choosing Uninstall.

Conclusion

WSL is a great utility. But to get full feature of Linux, it's better to run on a separate virtual machine.

Amazing! You now have the power of Linux right within your Windows system using WSL 2. Thanks for reading and please provide your suggestions in the below comment section.