Over a million developers have joined DZone.

The Windows Subsystem for Linux

DZone's Guide to

The Windows Subsystem for Linux

Windows Subsystem for Linux (WSL) makes your life easier by providing a bash shell to do several common tasks from development to administration.

· Integration Zone
Free Resource

The Integration Zone is brought to you in partnership with Cloud Elements.  What’s below the surface of an API integration? Download The Definitive Guide to API Integrations to start building an API strategy.

Microsoft has been increasing their support of Linux across Azure public cloud, Hyper-V and Linux Integration Services (LIS) and Windows platforms including Windows Subsystem for Linux (WSL) as well as Server along with Docker support.

WSL with Ubuntu installed and open in a window on one of my Windows 10 systems.

WSL is not a virtual machine (VM) running on Windows or Hyper-V, rather it is a subsystem that coexists next to win32 (read more about how it works and features, enhancements here). Once installed, WSL enables the use of Linux bash shell along with familiar tools (find, grep, sed, awk, and rsync, among others) as well as services such as SSH and MySQL, among others.

What this all means is that if you work with both Windows and Linux, you can do so on the same desktop, laptop, server or system using your preferred commands. For example, in one window you can be using Powershell or traditional Windows commands and tools, while in another window working with grep, find, and other tools eliminating the need to install things such as wingrep, among others.

Installing WSL

Depending on which release of Windows desktop or server you are running, there are a couple of different install paths. Since my Windows 10 is the most recent release (e.g. 1709) I was able to simply go to the Microsoft Windows Store via the desktop, search for Windows Linux, select the distribution, install and launch. Microsoft has some useful information for installing WSL on different Windows version here, as well as for Windows Servers here.

Get WSL from the Windows Store or more information and options here.

Click on "Get the app."

Select the desired WSL distribution.

Let's select SUSE, as I already have Ubuntu installed (I have both).

SUSE WSL is in the process of downloading. Note that SUSE needs an access code (free) that you get from https://www.suse.com/subscriptions/sles/developer/; while waiting for the download and installation is a good time to get that code.

Launching WSL with SUSE, you will be prompted to enter the code mentioned above; if you do not have a code, get it here from SUSE.

The WSL installation is very straightforward: enter the SUSE code (Ubuntu did not need a code). Note the Ubuntu and SUSE WSL task bar icons circled in the bottom center.

Provide a username for accessing the WSL bash shell along with a password, confirm how root and sudo are to be applied, and that is it. Seriously, the install for WSL- at least with Windows 10 1709- is that fast and easy. Note that in the above image, I have WSL with Ubuntu open in a window on the left, WSL with SUSE on the right, and their taskbar icons bottom center.

Using WSL

Once you have WSL installed, try something simple, such as viewing your present directory:


Then look at the Windows C: drive location.

ls /mnt/c -al

In case you did not notice the above, you can use Windows files and folders from the bash shell by placing /mnt in front of the device path. Note that you need to be case-sensitive such as User vs. user or Documents vs. documents.

As a further example, I needed to change several .htm, .html, .php and .xml files on a Windows system whose contents had not yet changed from http://storageio.com to https://storageio.com. Instead of installing wingrep or some tools, using WSL such as with Ubuntu finding files can be done with grep such as:

grep "http://storageio.com" /mnt/c/Users/*.xml

And then making changes using find and sed such as:

find /mnt/c/Users -name \*.xml -exec sed  -i "s,http://storageio.com,https://storageio.com,g" {} \;

Note that not all Linux apps and tools can use file via /mnt, in which case a solution is to create a symbolic link.

For example:

ln -s "/mnt/c/Users/Test1/Documents"  /home/Test1/Projects

What This All Means

If you primarily work on (or have a preference for) Linux systems and need to do some functions from development to the administration or other activity on a Windows system, Windows Subsystem for Linux (WSL) provides a bash shell to do familiar tasks. Likewise, if you are primarily a Windows person and need to brush up on your Linux skills, WSL can help. If you need to run Linux server applications or workloads, put those into a Docker container, Hyper-V instance or Azure VM.

Overall I like WSL for what it is, a tool that eliminates the need of having to install several other tools to do common tasks, plus makes it easier to work across various Linux and Windows systems including bare metal, virtual and cloud-based. Now that you have been introduced to Windows Subsystems for Linux WSL and an overview including install as well as using, add it to your data infrastructure toolbox.

The State of API Integration Report provides data from the Cloud Elements platform and will help all developers navigate the recent explosion of APIs and the implications of API integrations to work more efficiently in 2017 and beyond.

data infrastructure ,datacenter technologies ,cloud

Published at DZone with permission of Greg Schulz, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}