Overview
The focus of the Crypto Lab series is to provide some useful information on some tools and controls used in systems security engineering, with a cookbook approach.
This page will focus on the installation, care and feeding of the Windows Subsystem for Linux (WSL), by far the most interesting feature that Microsoft has introduced to Windows – ever.
Essentially (to paraphrase and slightly mangle) WSL is a very substantial command line version of Ubuntu Linux, that runs directly on top of the Windows kernel. This has technically been possible since NT4.0, which had a POSIX kernel, and was derived from Dave Cutler’s work at DEC on VMS. Essentially the NT4.0 kernel was the first fully abstracted kernel with preemptive multitasking – just like the mainframes. This architecture allowed for any operating system to be built on top of this kernel as a subsystem, but unfortunately from 1993 to 2016, the only available options were the Windows subsystem. This architecture also allowed Windows to be ported to other CPU architectures like the MIPS, DEC Alpha and the PowerPC by rewriting parts of the kernel and parts of the HAL (Hardware Abstraction Layer), while leaving nearly all of the OS itself unmodified.
Fast forward to 2017, Windows runs on IA32/64 platforms (without any alternative CPU options), and Microsoft in partnership with Canonical have developed a native Linux subsystem that runs in parallel with the Windows operating system.
It is limited to the command line, although there are some hacks to enable an approximation of a Linux Desktop (ie VNC). In the following sections we will outline how to enable, install and maintain WSL on your Windows 10 installation.
Setting up Windows Subsystem for Linux (WSL)
Installation
- Verifying your version of Windows 10: In the search box, enter ‘about’ and select the ‘About your PC’ option. The window should be similar to this and it must indicate build 14393 or greater and 64 bit operating system.
- Enabling Developer Mode: In the search box, enter ‘developer’ and select the ‘For Developer Settings’ option. The window should be similar to this. Enable Developer mode.
- Installing WSL: In the search box, enter ‘features’ and select the ‘Turn Windows features on or off’ option. The window should be similar to this. Check the ‘Windows Subsystem for Linux (beta)’ option, and click ‘OK’.
- Powershell Enabling: In the search box, enter ‘powershell’ and right click over the ‘Powershell’ option, and select ‘run as Adminstrator’, and confirm. In the Powershell window enter:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Follow the prompts and reboot if it calls for it.
- Bash Installation: In the search box, enter ‘cmd’ and select the ‘Command Prompt’ option. Type ‘bash’ and enter. Follow the prompts. Create a username and password when prompted. This user/password has nothing to do with any of the Windows accounts and is specific to the WSL instance.
- Bash Operation: In the search box, enter ‘bash’ and select the ‘BASH on Ubuntu on Windows’ option.
- Updating Bash: In the Bash window, enter:
sudo apt-get update sudo apt-get upgrade
Fun and Games with WSL
- WSL About: From inside the Bash window, enter:
sudo lsb_release -a
- WSL Driving Mappings: From inside of the Bash window, enter:
ll /mnt/c
- Explorer OpenWSL: Download the open-wsl terminal (https://github.com/goreliu/wsl-terminal). In the tools directory run the JS-App “add-open-wsl-here-menu.js”. This will allow you to right click in any directory and open a WSL terminal to that directory.
Care and Feeding of WSL
- About LXRun: From a Windows command prompt, enter:
lxrun
- Uninstalling WSL Instance: From a Windows command prompt, enter:
lxrun /uninstall /full
- Resetting WSL Environment: From a Windows command prompt, enter:
C:\> lxrun.exe /uninstall /full
C:\> lxrun.exe /install
- Updating WSL: This appears to be exactly the same as apt-get update/upgrade. From a Windows command prompt, enter:
lxrun.exe /update
Wrapup
Note that this does not represent the authoritative source for any of this material. For that please refer to the links below. This is just intended to be a more concise aggregation of the more interesting items provided in the links below.
References
- https://en.wikipedia.org/wiki/Windows_NT
- https://blogs.msdn.microsoft.com/wsl/2016/04/22/windows-subsystem-for-linux-overview/
- https://msdn.microsoft.com/en-us/commandline/wsl/install_guide
- https://msdn.microsoft.com/en-us/commandline/wsl/faq
- https://blogs.windows.com/buildingapps/2016/07/22/fun-with-the-windows-subsystem-for-linux
- https://msdn.microsoft.com/en-us/commandline/wsl/about
- https://msdn.microsoft.com/en-us/commandline/wsl/reference
- https://blogs.msdn.microsoft.com/commandline/
- https://github.com/goreliu/wsl-terminal
- https://github.com/RoliSoft/WSL-Distribution-Switcher