How to install or reinstall Windows Subsystem for Linux

Related:


Ubuntu 16.04 is available on the Microsoft Windows Store. It requires Windows Build ≥ 16215 or Fall 2017 Creators Update.

Install Ubuntu Linux via Windows Store

  1. enable Linux by typing in Administrator Powershell:
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    

    Alternatively, you can do this via the GUI by Start → Turn Windows features on or off → Windows Subsystem for Linux.

  2. reboot PC
  3. go into Windows Store and install Ubuntu.
  4. an “Ubuntu” icon is created, perhaps pin it to your Start Menu for convenience.

Or, start Ubuntu by typing in Windows Command Prompt:

Ubuntu

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 on Windows

  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

WSL Beta users should upgrade to Ubuntu Windows Store app

If you have the “beta” WSL already installed, the new Ubuntu Windows Store app installs side-by-side. It is recommended to transition to the new Ubuntu app as the beta WSL will be deprecated.

  1. transfer your beta WSL user files out of WSL
  2. Uninstall the beta WSL app from Windows Command Prompt:
    lxrun /uninstall
    

Error: 0x80040154

If you’ve just upgraded to a new Windows Build, be sure that Start → Turn Windows features on or off → Windows Subsystem for Linux is still checked.

Leave a Comment