Using Linux on Windows (Microsoft WSL)

(These notes were developed based on Windows 10 build 1607 and 1709. The advice should be approximately correct for more recent Windows 10 builds.)


Installing WSL: Windows Subsystem for Linux

  1. PART I
    1. Type: "control panel" in search box next to start button.
    2. Select: Programs -> Turn Windows features on or off
    3. Check box next to: "Windows Subsystem for Linux"
  2. Windows will then want to re-boot
  3. PART II (This part was needed only for older Windows 10 builds. You can probably skip this part.
    1. Then open "Settings"
    2. Select: Update & Security -> For Developers
    3. Check "Developer mode" (This allows you to run programs from outside the Windows Store, such as Linux-based programs. As always, beware of what you allow to run.) P.S.: If you see error code 0x80004005. see below for the fix.
    4. While you're there, some of the options in "Windows Explorer" might also be interesting for you.
  4. Windows may then recommend to re-boot
  5. PART III (for older Windows 10 builds)
    1. After that, you can type: bash in the search box next to Start button
    2. It will then ask permission to download some Linux utilities from the Windows store, distributed by Canonical. (Or more recently, it will show you the URL where you can go to install a Linux distro -- currently Ubuntu (a common choice) or Suse. Doing this will consume a little more than a gigabyte disk space.)
  6. PART III (for newer Windows 10 builds)
    1. Go to the Microsoft Store; and choose your favorite version of Linux. (Ubuntu is a common choice.) Install it.
    2. Go back to the search bar and type bash again to start a Linux session in a terminal window.
  7. PART IV
    1. Using copy-paste in the bash terminal window:
        Copy: highlight region of text with mouse and hit <ENTER> key
          Paste: right-click with mouse
        • If this doesn't work for you; try: From Properties menu, select options tab and enable QuickEdit Mode, and maybe also Insert Mode (right-click for insert). After this, control-insert should work for "copy" and mouse right-click should work for "paste".
  8. PART V
    1. Some recent Windows laptops (e.g., some Lenovos) place an up-arrow key where the right-shift key should be. You'll need the right-shift key to touch-type vi commands. If you have that problem, try: KeyTweaks or this key remapper (and always beware of where you download software from)
  9. PART VI
    1. To allow Linux and Windows to communicate, you have to set up some links. On the Linux/bash side, do: ln -s /mnt/c/Users/USERNAME/Desktop Desktop
      where you replace USERNAME by your Windows username, and so on.
      On the Windows side, create a link to
      On the Windows side, optionally go to File Explorer, and do: File->Options->View and "Show Hidden Files".
    1. Since the April-2018 update of Windows 10 to version l1803, there has been a long-standing bug. On startging bash, the terminal window tells you that your WSL (e.g., Ubuntu) is not available. In fact, it is available, and if you wait 5 minutes and again invoke bash, then it will work properly.
    2. This bug is analyzed here. It was diagnosed by users as a problem with the lxssManager using the fast startup mode. There are some ways discussed there to re-configure Windows to a non-default mode that might fix the bug.
    3. A user from that discussion, @behillis, (maybe working for Microsoft??) wrote on July 31 that he expected that Microsoft would push out the bug fix in about a month. As of the September Windows update, this bug is not yet fixed.
    4. Based on all this, I am guessing that Microsoft knows how to fix the bug, and is planning to include the bug fix in one of the future Windows updates. Please do suffer through the 5-minute delays in the interim. It will be worth the wait.
    In some older Windows 10 builds, you might have seen certain errors. If you see "developer mode package failed to install" (error code 0x80004005) when enabling developer mode, please see here, for the Microsoft workaround.

    After trying this, if you're missing your favorite Linux program, try:
        sudo apt-get install PROGRAM
    I suggest:     sudo apt-get install gcc gdb make Here is the Microsoft reference page.

    You can uninstall Windows Subsystem for Linux at any time through the Windows store ( or through the original method of opening a "cmd" window, and typing:
        lxrun.exe /uninstall

    Linux Graphics Applications under WSL

    If you should want to run a Linux graphics application, then first practice running a graphics application at on your local Windows laptop. This will be slow since all graphics will go over the Internet. Try out, for example, this tutorial from UCI.

    Then try this, using similar principles from your bash shell:

    Essentially, the idea is to start a _Windows application_, Xming, or else vcxsrv. This will create an X-server as a Windows application. Now, since your Linux graphical application wants to talk to a Windows application on the same host, we can simply do (from inside the Linux bash shell):
    1. sudo apt-get install LINUX_PROGRAM

    Digging deeper into how Linux and Windows can co-exist

    If you would like to dig deeper, and also sharpen your understanding of operating systems, here is an overview of what is happening in WSL:
    A quick look into LxRun.exe: Windows 10’s new Linux downloader and installer

    WSL also allows you to substantially share a Linux filesystem with a Windows filesystem. If you're curious about how two different filesystems can coexist, try reading:

    Philosophy; and looking into the crystal ball to see what the future might hold for us

    Philosophizing: We have seen a recent growth in diversity in widely used operating systems:

    In a countervailing trend, there are efforts to merge certain operating systems into a single operating system that supports multiple platforms. We see this especially between smartphone and laptop:

    Digging deeper into the operating systems research behind this new direction by Microsoft

    One of the more interesting things to watch in the development of mainstream operating systems is the extension of Windows 10 (especially the recent Windows 10 Anniversary Edition) to include support for Windows smartphone apps, iOS, the now suspended Project Astoria for supporting Android, and now WSL (Windows Subsystem for Linux). In fact, WSL grew out of Project Astoria, since the Android target of Project Astoria is already based on Linux. (The vision of Project Astoria, presumably, was to allow Android apps to run on Windows smartphones.)

    Microsoft calls this effort Universal Windows Platform (UWP):

    If you want to dig deeper into the origins of this effort, read this overview, and a widely cited Microsoft research paper:

    And here's where the internal development of WSL is taking place within Microsoft. Microsoft is providing a relatively open window for the rest of the world to look in on this project.