Windows Subsystem for Linux

January 14, 2021 — November 23, 2021

computers are awful
MS Windows
Figure 1

Historically there are a thousand small annoyances in getting software developed for linux to run on windows. Since 2020 or so, the number of annoyances has been vastly reduced by Window Subsystem for Linux (WSL) WSL installs a miniature Linux distro backed by the Windows OS, that runs within Windows. This means that I can copy-paste linux setup instructions for my favourite software packages into a terminal on my windows machine and have it run. For activities like cloud compute, which usually presume the cloud is made of linux, this is extremely helpful, since there is less likely to be difference between installing my development environment locally and on the cloud.

Here are my notes on that.

There are two flavours of WSL: WSL1 and WSL2. I understand they are backed by different technology, the distinction between which has been written about in various places, and I am hoping I do not need to care about. tl;dr; everyone is using WSL2 now; I will do my best to learn nothing about WSL1.

1 Installation

Classic install procedures have changed a lot, so it is worth googling At time of publication, the Microsoft official instructions are now simply to run PowerShell as administrator and execute:

wsl --install

I find the Ubuntu explanation enlightening to understand what is actually going on:

The recommended way to install Ubuntu on WSL is through the Microsoft Store.

The following Ubuntu releases are available as apps on the Microsoft Store:

  • Ubuntu 20.04 LTS (Focal) is the current LTS release, supporting both x64 and ARM64 architecture.
  • Ubuntu (without the release version) always follows the recommended release, switching over to the next one when it gets the first point release. Right now it installs Ubuntu 20.04 LTS.

Each app creates a separate root file system in which Ubuntu shells are opened but app updates don’t change the root file system afterwards. Installing a different app in parallel creates a different root file system allowing you to have both Ubuntu LTS releases installed and running in case you need it for keeping compatibility with other external systems. You can also upgrade your Ubuntu 16.04 to 18.04 by running do-release-upgrade and have three different systems running in parallel, separating production and sandboxes for experiments.

2 Invocation

After installing, say, an Ubuntu distro I have an ubuntu.exe command. Cute! But slightly confusing. The wsl command can launch many different distros, and even launch into particular apps inside a distro. This app is a favourite of mine.:

wsl fish

Each distro is effectively a separate customised virtual machine, AFAICS. This conflates the idea of the virtual machine and the software which runs on the virtual machine to my mind, but maybe this confusion is OK for the current purposes. Or maybe advanced users can disentagle these.

3 Compatible terminals

Windows and linux use different terminal standards, so if you are not satisfied with the build-in terminal emulation (I am not), you need to install a terminal app which runs on windows but understands posix. Pro tip: Cmder supports both windows and posix conventions


I hear reports that WSL GUIs run for some apps, if you have an X server. I suspect this is not officially supported? Anyway, worth trying. It will need a Windows-compatible X-server I suspect. Here are two options that were mentioned on the chat at work:

5 Incoming