Launching Windows application on Windows subsystem for Linux (WSL)

In mid-2016, I attended an open source conference that talked about how Microsoft changed their view on open source software. It is now one of the most active contributors in the open source community. This knowledge, coupled with the disappointing release of the MacBook pro last October 2016, have made me decide to continue using Windows as my main development machine.

Windows subsystem for Linux (WSL) or sometimes called “Windows bash” gives you access to a bash terminal on Windows 10 machines. It is a native Linux environment, where you can do all sorts of Linux commands, that is supposedly better than MinGW or Cygwin. The main goal, I think, is to provide a better development environment on Windows while addressing the limitations of the DOS command line and the Windows powershell. It is quite amazing as you can use both Windows and Linux applications on the same machine accessing the same environment.

Just last month, I upgraded my Windows 10 version to the creator’s update. With this update, WSL now uses Ubuntu 16.04 LTS. Soon, Microsoft will allow you to choose your own flavor of Linux. This update comes with a lot of improvements on Windows bash. I can now completely uninstall my Windows version of node js and still run node js applications. It has been possible to do this before the said update, but it was a little buggy; for example, node applications not being able to receive an HTTP request from the Windows environment.

Some work I do in WSL includes, SSH to remote servers, do git commands, connect to Kubernetes cluster using kubectl, manipulate MongoDB data, and so on. I have almost completely replaced my cmd with WSL. Developing on windows has become so convenient, we may not need to install any development tools on Windows anytime soon; just install and run everything on WSL.

Now one of the best features of this update is that the Linux environment can execute Windows applications like how it works on Mac OS, albeit some limitations. One problem I faced was being unable to open Atom using WSL. I discovered that putting a corresponding alias in the ~/.bashrc file addressed the issue. So I added this line:

alias atom=’/mnt/c/Windows/System32/cmd.exe /c “atom”’

Now I am able to use [atom .] on WSL to open the Atom editor on Windows.

I can also use docker commands this way, by adding another line to my bashrc file like the one below:

alias docker=’/mnt/c/Windows/System32/cmd.exe /c “docker”’

You may want to also include docker-compose and other docker commands as an alias to make the docker experience in WSL a complete package.

This is one of the best features Windows can provide to the developer community. I hope they keep on perfecting this in the future so that we can just install all development tools in WSL and keep our Windows system clutter free.

Happy coding.