Guide-to-install-Windows-Subsystem-for-Linux-WSL-2-on-windows-10

Step-by-Step Guide To Install WSL 2 On Windows 10

The WSL( Windows Subsystem for Linux ) helps developers to run a GNU/Linux environment along with its utilities, command-line tools, and application directly on Windows, without the help of traditional methods like a virtual machine or dual-boot setup.

What’s new in WSL 2?

  • WSL 2 is a new version of the Windows Subsystem for Linux architecture that helps to run Linux distribution on Windows natively (using a lightweight virtual machine).
  • WSL 2 is the upgraded version of WSL1 (the current widely available version). Its primary goal is to increase file system performance and add a full system call compatibility.
  • Linux distributions can be run with either the WSL 1 or WSL 2 architecture and can be upgraded or downgraded at any time. 

Before you install WSL 2, let’s check whether your system can run it or not.

  • If you have an x64 system: Version 1903 or higher, with Build 18362 or higher.
  • If you have an ARM64 system: Version 2004 or higher, with Build 19041 or higher.
  • WSL 2 do not support Builds lower than 18362
NOTE 
To check your version and build number, select Windows logo key + R, type winver, select OK.

Getting started on windows

Step 1: Enable the WSL ( Windows Subsystem for Linux )

  1. Open Command Prompt or PowerShell  and run it as administrator
  2. Enter and execute this command –
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
how-to-enable-wsl-windows-subsystem-for-linux

Step 2: Enable the Virtual Machine Platform

  1. To enable Virtual Machine Platform  execute this command next-
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
how-to-enable-virtual-machine-platform-in-windows-10

Restart your computer to complete the WSL install.

Step 3: Download the Linux kernel update package

  1. Download the latest package from here: WSL2 Linux kernel update package for x64 machines

Install the package.

NOTE: If you’re using an ARM64 machine, then download the ARM64 package instead. If you’re not sure what kind of machine you have, open Command Prompt or PowerShell and enter: systeminfo | find "System Type".

Step 4: Setting WSL 2 as your default version

Now in your Command Prompt, enter this code:

wsl --set-default-version 2

Step 5: Install Linux distribution

  1. Open Microsoft Store and install any Linux distribution of your choice.
windows store ubuntu

The first time you launch installed Linux distribution, you’ll be asked to wait for a minute or two for files to be stored on your PC. In the future, launches should take less than a second.

You will be asked to create a user account and password for the Linux distribution( Make sure to write down the password somewhere in case you forget it ).

install ubuntu

CONGRATULATIONS! You’ve successfully integrated your Linux distribution with your Windows operating system!

Step 6: Checking the WSL Version

You can check the WSL version by entering this command in your cmd.

wsl --list --verbose
checking wsl version

In Case your wsl version is set to 1, you can change it by running this command :

wsl --set-version <distribution name> <versionNumber>

Replace <distribution name> with the name of your distribution and <versionNumber> with the number ‘2’ or vice versa.

In case you get any error while doing any of the steps mention above. Worry not and follow this Troubleshooting Installation Guide for solutions.

Step 7: To get into your Linux distribution

Open command prompt and run command – wsl

Take a closer look! The current path is pointing to your Windows User Directory.

wsl-2-starting-linux

Now, it is recommended to store source code and other bind-mounted data into Linux containers in the Linux file system rather than the Windows file system.

So, execute the command – ” cd ~ ” to get into the Linux User Directory.

WSL 2 changing to linux directory

WELL DONE! You are all set!

Thank You for reading till the end. If you find this article useful, don’t forget to save it and share it with your friends.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.