Windows Subsystem for Linux

From OSDev Wiki
(Redirected from WSL)
Jump to: navigation, search

Windows Subsystem for Linux (or WSL) is an official compatibility layer of Microsoft Windows which allows Windows users to use Linux applications without virtual machines or a third-party program like Cygwin. WSL includes a Linux-compatible kernel capable of running ELF executables, along with a Bash shell and standard Linux command-line tools.

Due to the ubiquity of Linux in programming (with OS Development being no exception) and the various programs and libraries which are only designed to run on Linux machines, WSL may prove useful to any Windows-using OS developers.

Contents

Availability

Windows Subsystem for Linux is only available on 64-bit Windows 10 machines running the Anniversary Update or later (check by opening System>Settings>About).

Note that the way you use the WSL changes depending on what update you're on. See the Microsoft Documentation on WSL for details.

Installing Windows Subsystem for Linux

To enable Windows Subsystem for Linux, follow these steps:

  • Put your computer into Developer Mode. to do this:
    • Open settings
    • Select "System & Security"
    • Select the "For Developers" tab
    • Select the "Developer Mode" radio button
  • Enable the Windows Subsystem for Linux feature via either the GUI or the Command Line
    • GUI:
      • Open the "Turn Windows features on or off" utility (try searching for it in Start)
      • Enable "Windows Subsystem for Linux (beta)"
      • Click OK
    • Command Line:
      • Open PowerShell
      • Run
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    • When prompted to reboot, do so.
  • Go to the Windows Store and install your distro of choice.
    • If installing Ubuntu, you do not want the Ubuntu package. That is Ubuntu 16.04, and is far too outdated to be useful, as it uses GCC 5. Ubuntu 18.04 is now available with the more modern GCC 7, and GCC 8 on apt.

Assuming no errors are given, Windows Subsystem for Linux should now be installed.

Using Windows Subsystem for Linux

  • To start your distro of choice, there are two options:
    • GUI
      • Create a start manager shortcut to your distro and click that
    • Command Line
      • Type "wsl" in the command line. This will launch your default distros default shell.
        • Note that you can change the default distro using wslconfig, and the default shell through normal means.
  • Run your programs and utilities.
    • Note that you can run windows programs from the WSL, including from the windows PATH, but you have to append the file extension to them.
      • Ex: notepad.exe will work.
      • script.py will also work, if script.py is on your windows path and has the appropriate shebang. This will run using the distro Python.
        • python.exe script.py will not work, as thats not a full path. where script.py will reveal the full path, which then works.
        • Interactive windows apps such as this work less than well from the WSL at the time of writing.

At this point, you have access to the wide array of command line utilities for Linux. But maybe you want more, maybe you want GUI apps too.

GUI apps are officially unsupported by the WSL at the moment, but for the most part they work fine if you install an X server such as VcXsrv.

After installing an X server, you simply export DISPLAY=0 and GUI apps will start working usually. Notably, QEMU works quite well in this manner if you don't want to install it on windows for whatever reason. You may also wish to install a terminal emulator to improve the WSL experience. Windows tabbed terminal emulators are.. lacking to say the least, but installing something such as Terminator works quite well.


See Also

External Links

Personal tools
Namespaces
Variants
Actions
Navigation
About
Toolbox