Windows Subsystem for Linux (WSL)

A short and happy guide


What is Windows Subsystem for Linux?

WSL is a collection of components that enables native Linux ELF64 binaries to run on Windows. It contains both user mode and kernel mode components.


Windows Subsystem for Linux components

  • User mode session manager service that handles the Linux instance life cycle
  • Pico provider drivers (lxss.sys, lxcore.sys) that emulate a Linux kernel by translating Linux syscalls
  • Pico processes that host the unmodified user mode Linux (e.g. /bin/bash)

Details


What does that mean?

You have full fidelity to run the majority of Linux distributions and binaries without the requirements of a Virtual Machine

Yes it WORKS and it does seem like dark magic but you REALLY can run native Linux binaries quickly and without the hassles and constraints of dual boot, virtual machines, etc


Installing Windows Subsystem for Linux

Powershell command run as Administrator

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

Or Enable from Windows

And you most likely will need to enable Developer Mode


Install a Linux Distribution

I use Ubuntu LTS (18.04), you should use this too if you are not particular about Linux distributions.

  • Go to the Microsoft Store and search for Ubuntu -> pick 18.04 installation
  • If you are unable to access this install from the common folder CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2018.817.0_x64__79rhkp1fndgsc.Appx
  • You will most likely need to reboot/etc

Create a User Account

  • This account will have the ability to sudo or elevate its privileges to root so don't forget your password

Open a Bash Terminal

You can search for the Ubuntu 18.04 Terminal command like

I strongly recommend you pin this program to your taskbar


The Terminal

You should be greeted with the following command line

Note that the default prompt is username@machinename you can change this if you would like under the .bashrc, more details here


Basics


It's still on a Windows filesystem though

  • cd /mnt/c/Users = Change to the c:\Users directory
  • You can launch Windows executables from this system too like i.e. explorer.exe "c:\Windows\System32\drivers\etc"
  • notepad.exe "c:\Windows\System32\drivers\etc\hosts"

YES it works, but warning this can cause conflicts if you get duplicate Linux binaries and have the same Windows binaries in my case Docker (don't do it unless you like pain)


Something interesting

apt-get moo
And what did you get....

Ok now try
cmatrix you will most likely need to install the package from the Ubuntu package manager apt-get the command is:
sudo apt-get install cmatrix

And....


A little bit more practical

Extract all links from homepage

sudo apt-get install lynx && lynx -accept_all_cookies -dump www.amazon.com | grep "http" |sed -e "s/^.*http/http/"


Conclusions

  • Windows Subsystem for Linux is all the good parts of Linux without the hassle, seamless integration with your current system
  • Full featured and ability to run ELF64 binaries is an incredible plus
  • Experimentation with scripting can be done locally and tested
  • A huge open community of experts and proven tested code is available for you to work with

Your thoughts?


Thank you

If you want to know how to run X-Windows or GUI based Linux applications that is possible as well, but in another talk ;)