Linux On Windows (WSL 2)

7th February 2021

Systems

Did you know, you can now run Linux on Windows 10, finally you can grep Windows files to your heart's content!

You can read more about Windows Subsystem for Linux (WSL) on the Microsoft website.

https://docs.microsoft.com/en-us/windows/wsl/about

 

Installing WSL 2

Installing WSL 2 is nice and easy:

  • Search for "Turn Windows features on or off" in the start menu
  • Find and check "Windows Subsystem for Linux", then click OK
  • Finally, restart your computer

Windows Feature Dialog

To install via PowerShell, run the following command as an administrator:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

As long as you are running a build of Windows that supports it, you can update to WSL 2. I have found this to work better and more nicely with other software, for example I used to have an issue with Virtual Box VMs when WSL 1 was installed.

Back in the Windows Features dialog, check "Virtual Machine Platform" and click OK, then reboot. If you want to do it via PowerShell run:

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

After the restart you then want to go to this website (https://docs.microsoft.com/en-us/windows/wsl/install-win10) and download the WSL 2 Kernel Update.

To finish enabling WSL 2, run the following in PowerShell:

wsl --set-default-version 2

I would do one last restart just to ensure everything is updated and loaded.

 

Installing Linux Distributions

Now that we have WSL 2 installed, we can go ahead and install a Linux distribution, in this post we are using Ubuntu 20.04.

Navigate yourself to the Windows Store and search for "Ubuntu".

Screenshot of Windows Store showing search result for Ubuntu

Click on "Ubuntu 20.04 LTS" and then click the "Get" button. You will need to be signed into a Microsoft account to do this but its free.

Once it has downloaded and installed run it by searching for "Ubuntu", upon first running you will be prompted for a username and password.

Screenshot of Ubuntu running first time

You are now ready to start using Linux on Windows.