The ultimate bioinformatics tool for Windows - the Linux Subsystem for Windows 10

Linux is one of the most important tools in Bioinformatics - serving as the platform for many tools and services, and the Desktop of choice for many.

The ability to use this familiar *NIX system, yet also have a portable and usable desktop work environment has led many in the field to use MacBook Pros/Airs. Sitting in any bioinformatics meeting you will be surrounded by glowing white Apple logos!

I was an Apple user for many years, precisely because of this blend of function and *NIX environment. However, I have now made the day-to-day transition to Windows - a Surface Pro 4 - because of this device's fantastic usability and Windows' new hidden Linux talents.

Ok - so I still have a Linux workstation for serious/heavy use, but the ability to use familiar programs and PERL code (avoiding the whole line endings and / \ path issues) now makes the Surface an awesome main machine.

So how does this work - the Linux Subsystem for Windows! This has been referred to in the media most often as Bash on Windows - but it is so much more than that!

It brings the workhorse of bioinformatics right into the Windows desktop - no VMs, no Docker, no Cygwin. It's early-days for this "experimental" feature, but it is already looking like a powerful, and useful addition.

Installing the Linux Subsystem for Windows

The Linux Subsystem for Windows is still experimental, but can now be used by anyone who has the Windows 10 Anniversary edition installed. I've been using it for a while as part of the Windows Insider Programme, before its release with the Anniversary edition.

To install it, you first need to turn on developer mode in settings:

developer mode

and then activate the Linux Subsystem for Windows from Control Panel -> Programs and Features - there is a tick box under Windows features. When you tick this your machine will need to restart, and then you are ready.

windows feature selection

Open a Windows Command Prompt and type "bash" - the Linux Subsystem will download and install (you will have to set a new Linux username) - and drop you into a Bash shell.

As I said before - this is much more than just a Bash shell for Windows though!

This is a collaboration between Microsoft and Canonical, who bring you Ubuntu. The Linux Subsystem for Windows is a complete installation of Ubuntu 14 - installed (and hidden) in C:\Users\username\AppData\Local\lxss

This means you can (almost) do anything in this shell that you could do with a Linux system - with full access to your Windows files and user-space (mounted at /mnt/c)

linux and windows filesystem

As an experimental feature there are some limitations: running servers/services like Apache are not really feasible; user permissions are not secure; and GUI/Desktop environment is not possible (although see the section on X-Windows below).

However, this Linux system is ideal for command line programs - many Bioinformatics tools and pipeline development, SQL databases etc - and especially my scripting language of choice, PERL. And, most importantly this system gives you native ssh for accessing remote machines - no more PuTTY!

Package management

All software can be managed/added to the Linux Subsystem by using the standard command line package manager for Ubuntu - apt-get. This has complete access to all of the regular software repositories you would have on an Ubuntu 14 installation.

Additionally, for PERL, you can manage packages in the usual way with CPAN or install them yourself once you have added the basic gcc/make toolset using apt-get.

Finally - and just for the sake of showing off - you can install packages using the GUI tool Synaptic, if you follow the next steps for using X-Windows from Bash on the Windows desktop. If you want to try this, install Synaptic:

sudo apt-get install Synaptic

Even X-windows

Let’s use the example of Synaptic to demonstrate the use of X-Windows from the new Bash shell. First, you need to download and install Xming on Windows. When you launch Xming you should get a system tray icon and nothing else at this point.

With Xming running, you have a fully-functional X-Windows system. You just need to tell programs that you launch from the Bash shell where to send their display, which is done by launching them after setting the DISPLAY environment variable. So, assuming you have used apt-get to install Synaptic, and have Xming running - to launch Synaptic with administrator permissions to install software you would use:

DISPLAY=:0 sudo synaptic

You should have the Synaptic window appear on your Windows desktop allowing you to search, select and install Ubuntu packages into the Linux Subsystem!

Synaptic in Xming

Getting PERL to work properly

I said that my scripting language of choice is PERL (yes there are others, yes I can use them, yes - PERL is my favourite). PERL works as you would expect it to work on a "normal" Ubuntu system, although it turns out there are a couple of things to do to get it to work properly.

The first thing to do for installing modules etc is to ensure you have a working build environment with make and gcc etc.

sudo apt-get install gcc
sudo apt-get install make

Should be sufficient to get you up-and-running with this. However, there is another anomaly that took me a while to solve (thanks to this thread) that you need to fix. Without this step there is a strage effect whereby installation of PERL modules appears to work, you can see them on the system in the right place - but PERL can't see them (even with @INC set correctly!)

You need to edit /usr/lib/perl/5.18.2/ at line 94 from:

don't_use_nlink => undef


don't_use_nlink => 1

Installation of modules now works as expected! You can now go ahead and configure CPAN in the usual way - and use it, apt-get, Synaptic or manually install modules.

Windows Command Line tips

If you spend most of your time in linux then there will be a few things that are a bit different on the Windows command line.

If you have been around long enough, you will probably be familiar with enough DOS commands to navigate the system - and after all, you only opened that Windows shell to launch Bash didn’t you?

Regardless, there are likely to be times when you want a quick look around or to work with a file, and you will get your DOS/Bash commands mixed up. What if you could simply use a few simple Bash commands on windows?

Well - you can’t - but you can pretend! You can set Windows to recognise aliases for common commands. You need to create a short batch (.bat) or command (.cmd) file somewhere on your system with your aliases in. Then a quick registry tweak and these will be persistent for whenever you open a new Command Prompt.

The following example sets a linux-style "ls" command using DOS "dir /w", and a linux-style "clear" command mapped to DOS "cls". The final one makes use of Notepad++ to easily edit files from the command line with "nedit [filename]"

  • Create a .bat or .cmd file with your DOSKEY commands.
@echo off

:: Commands

DOSKEY ls=dir /w
DOSKEY clear=cls

DOSKEY nedit="C:\Program Files (x86)\Notepad++\notepad++.exe" $*
  • Run regedit and go to HKEY_CURRENT_USER -> Software -> Microsoft -> Command Processor
  • Add String Value entry with the name AutoRun and the full path of your .bat/.cmd file.

Now, when you open the Windows Command Line you can quickly use these commands without having to think about DOS!