Install Windows Subsystem for Linux

Ubuntu LTS releases among other Linux distros are available on the Microsoft Windows Store or command prompt. Install Ubuntu in WSL2 by:

wsl --install Ubuntu

WSL can use GUI and sound with programs like Spyder via WSLg.

Verify if on WSL1 or WSL2 by from PowerShell / Command Prompt:

wsl --list --verbose

The result will be like:

  NAME      STATE           VERSION
* Ubuntu    Running         2

Convert an existing WSL1 distro to WSL2 from PowerShell:

wsl --set-version Ubuntu 2

Install, list, and switch between Linux distros on Windows default for bash by from Command Prompt:


Limit the amount of RAM WSL2 can use by editing Windows file ~/.wslconfig to include:

memory=4GB  # arbitrary, set to less than your total computer physical RAM to help avoid using Windows swap

A WSL default that is confusing and slows down WSL program-finding is stuffing Windows PATH into WSL PATH. We normally disable Windows PATH injection into WSL, because it also breaks library finding in build systems like CMake. Additionally, we enable filesystem metadata, as weird permission errors can occur, even causing CMake to fail to configure simple projects.

Each Linux distro has its own /etc/wsl.conf We typically include in our /etc/wsl.conf:

enabled = true
options = "metadata"


The Windows file ~/.wslconfig file sets parameters for all Linux distros, versus the per distro /etc/wsl.conf discussed above. To avoid the use of Linux swap and excessive memory thrashing we include in Windows ~/.wslconfig:


Run Ubuntu apps from Windows Command Prompt or PowerShell:

wsl ls -l

Run Windows program from Ubuntu terminal:


Note that capitalization matters and .exe must be at the end.

If necessary to reinstall Ubuntu, copy off your Linux user files as the next step deletes them. From Command Prompt:

Ubuntu clean