5.1 Windows Subsystem for Linux (WSL)

20210218 Ubuntu is readily available on Microsoft’s Windows 10 where the Windows Subsystem for Linux (WSL) supports Ubuntu out of the box. This is the simplest option for installing Ubuntu if you already have Windows 10 (1709 or later) installed (see Settings\(\rightarrow\)System\(\rightarrow\)About).

To support GUI applications under WSL you will also need to install XMing or VcXsrv.

Microsoft also released WSLv2 in May 2020 to incorporate the Linux kernel directly within Windows, so as to deliver significant performance gains and support more applications.

The steps to install WSL and then Ubuntu on a Windows 10 system are provided by Microsoft and summarised here.

  • Install XMing on Windows (download, run, and choose the defaults for the installation).

  • Go to Turn Windows Features On or Off (Control Panel\(\rightarrow\)Programs\(\rightarrow\)Programs and Features), tick on the box Windows Subsystem for Linux to install WSL and reboot. The option can also be enabled from the PowerShell:

> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  • Go to Microsoft Store and search for the latest Ubuntu distribution and install it. It is a free application. Once you have obtained the app click the Launch button in the Microsoft Store. This will install and configure the Ubuntu distribution, including asking you to create a new username.

  • Launch Ubuntu from the Start menu or else type the command ubuntu in the Powershell.

  • For GUI applications run the command $ export DISPLAY=:0 in the Ubuntu terminal window.

Once you get to a shell prompt enter the following command to update the operating system:

$ sudo apt update && sudo apt upgrade

I would then also recommend installing wajig (see Chapter~7).

$ sudo apt install python3-pip
$ pip3 install wajig
$ wajig update
$ wajig distupgrade

Given that the system has just been upgraded the distupgrade here may report that there is nothing to be done.

For Ubuntu 18.04 the system can be started from the PowerShell with:

> ubuntu1804

Ubuntu is now running within Windows. The following commands then illustrate a GUI based command demonstrating an animated plot.

$ export DISPLAY=:0
$ pip3 install mlhub
$ ml configure
$ ml install animate
$ ml configure animate
$ ml demo animate

Further resources are available in other sections in this chapter, and from Simon Zhao.