How to install or reinstall Windows Subsystem for Linux

Related:


Ubuntu 16.04 via Windows Subsystem for Linux is available to Windows users (Build ≥ 16215 / Fall 2017 Creators Update) via the Windows Store.

Install Windows Subsystem for Linux from 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. a “Bash on Ubuntu on Windows” icon is created, perhaps pin it to your Start Menu for convenience.

You can also start Ubuntu by typing in Windows Command Prompt

Ubuntu

Example WSL use from Windows

Run Ubuntu apps from Windows Command Prompt

From Windows Command Prompt

bash -c "ls -l" 

Run Windows program from Ubuntu app

From Ubuntu WSL terminal

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

How to Reinstall Windows Subsystem for Linux

from Windows Command Prompt (this deletes the WSL filesystem, backup your WSL files first!)

Ubuntu clean

Then reinstall the Ubuntu WSL app by typing at Command Prompt

Ubuntu

List which WSL distros you have installed

You can install multiple WSL distros, and can list them and switch which is default for bash from Command Prompt

wslconfig

Reference

Microsoft’s official procedure for installing Windows Subsystem for Linux.

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.

Uninstall the beta WSL app after you’ve transferred your files by from Windows Command Prompt:

lxrun /uninstall

Error: 0x80040154

especially if you’ve just upgraded to a new Windows Build, be sure that under #2 above, Windows Subsystem for Linux (beta) is still checked. If it was checked, uncheck it, reboot, and check it again, then try to reinstall WSL again.

Leave a Comment