How to install or reinstall Windows Subsystem for Linux

Ubuntu 18.04 is available on the Microsoft Windows Store.

Install

  1. in Administrator Powershell:

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    
  2. reboot PC

  3. go to Microsoft Store and install Ubuntu

  4. start Ubuntu by clicking the Start Menu Ubuntu icon, or type in Windows Command Prompt:

Ubuntu

configure WSL

A WSL default that is confusing and slows down WSL program-finding is stuffing Windows PATH into WSL PATH. We normally disable this, because it also breaks library finding in build systems like CMake. Our default /etc/wsl.conf as edited from WSL contains:

[interop]
enabled=false
appendWindowsPath=false

Examples

Run Ubuntu apps from Windows Command Prompt

From Windows Command Prompt

bash -c "ls -l"

Run Windows program from Ubuntu app

From Ubuntu terminal

/mnt/c/Windows/System32/notepad.exe
  • capitalization matters
  • you must include the .exe at the end.

Reinstall Ubuntu

  1. copy off your Linux user files (the next step deletes them).

  2. Command Prompt:

    Ubuntu clean
    
  3. Command Prompt:

    Ubuntu
    

List installed Windows Linux distros

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

wslconfig

Notes

  • Microsoft’s official Ubuntu Windows app install procedure.

Error: 0x80040154

If you’ve just upgraded to a new Windows Build, try from Administrator Powershell:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux