Lead Image Craig Whitehead on Unsplash

Lead Image Craig Whitehead on Unsplash

Hands-on test of Windows Subsystem for Linux

Undercover

Article from ADMIN 42/2017
By
If you don't want to do without the main advantages of Linux on the Windows platform, the Windows Subsystem for Linux offers another option. We delve the depths of the Linux underworld and explain how you can optimize the subsystem.

The new Linux subsystem [1] has been around since the Windows 10 Creators Update; according to Microsoft, it can get by without a resource-consuming virtual machine (VM) and configuration. It is also said to offer a more native Linux feeling than the previous Cygwin [2] Linux environment. Linux users have used Cygwin on Windows for years, for example, to automate processes with shell scripts (e.g., mass Git checkouts), but it does mean recompiling Linux programs for Windows.

A look at the subsystem is worthwhile because of the surprisingly lightweight, process-based virtualization concept that just might catch on. In this article, I explain the limitations of the subsystem compared with native Linux and Cygwin, and I offer a number of customization tips that help make the subsystem fit for everyday use.

Installation

Users of Windows 10 Professional, at least, will be able to pick up the Linux subsystem easily. The subsystem runs natively on Windows and does not require an additional VM. If you do not want to create a Microsoft account during the install, you can install Ubuntu 16.04 LTS directly by using Windows PowerShell. As an administrator, the command

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

prepares Windows for installing the subsystem (Figure 1, top). Next, select Settings | Update & Security | For developers to enable Developer mode (Figure 2). Once the installation is complete, type bash to display the prompt (Figure 1, bottom). Like all applications under Windows, the bash shell shown in Figure 3 is launched from the Start menu by calling bash.exe.

Figure 1: Easy to confuse: PowerShell is at the top, the prompt at the bottom.
Figure 2: Windows users have to enable developer mode.
Figure 3: The Linux shell on Windows at least feels native.

Home Is Home

After double clicking on bash.exe, you will find yourself in a Linux shell with an Ubuntu environment. Even the Apt package manager is there waiting for you. Windows saves the subsystem files under C:\Users\<pa>\AppData\Local\lxss. Conversely, Ubuntu mounts Windows under /mnt/c.

To save typing and avoid redundant data structures, it is best to merge the Linux and Windows home directories first. For this purpose, change the path to your Linux home directory in the /etc/passwd file so that it points to your Windows home /mnt/c/users/<pa>. The Vi editor, which you call by typing sudo vi /etc/passwd, helps you do this on Windows. After restarting Bash.exe, you land directly in the Windows home directory.

Startup Problems

Differences from a native Linux system are already apparent with the use of a user-specific C:\Users\<pa>\AppData\Local\lxss path: In contrast to the normal procedure, the services that Ubuntu usually links in the /etc/init.d directory do not start up automatically at boot time. They also terminate along with the shell. Although the Apache web server can be configured in the usual way, you have to boot it manually every time. After closing Bash.exe, it cannot be reached at all.

A command to register a Linux service under Windows (e.g., cygrunsrv under Cygwin) does not yet exist for the new subsystem. However, you can live with this restriction, because you will always open a shell to start work.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=