Windows Subsystem for Linux WSL has available Ubuntu LTS releases among other Linux distros on the Microsoft Store, which is the recommended method to install WSL. 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 feature set.
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=0GB 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.