Install Windows Subsystem for Linux
Windows Subsystem for Linux WSL has Ubuntu LTS releases among other Linux distros on the Microsoft Store. The Microsoft Store is the recommended method to install WSL. If on trying to run WSL the first time a message appears like:
The Windows Subsystem for Linux optional component is not enabled. Please enable it and try again.
Enable WSL by Win + R and type “optionalfeatures”, then check “Windows Subsystem for Linux”.
If the Microsoft Store isn’t available on the computer due to corporate policy etc., manual WSL install is also available – but use the Microsoft Store if possible. The WSL changelog shows the continually expanding WSL feature set.
WSL can use GUI and sound with programs like Spyder via WSLg.
List WSL distros already installed on the computer from PowerShell / Command Prompt:
wsl --list --verbose
Install, list, and switch between Linux distros on Windows default for
bash from Command Prompt:
Limit the amount of RAM WSL2 can use by editing Windows file ~/.wslconfig to include:
[wsl2] swap=0 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:
[automount] enabled = true options = "metadata" [interop] enabled=false appendWindowsPath=false
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.