GeekSocket Plug in and be Geekified

Bash on Ubuntu on Windows

WSL - featured

Sometimes you need tools from Linux like compiling c, cpp in gcc, grep, git.

Alternatives for Windows are available but all are not efficient.

Sometimes you need to try these tools, what you do is installing Ubuntu in VMWare or Virtual Box. Another alternative is Multiboot.

But what if we had all these tools/Ubuntu in Windows itself? It will make it super easy to work with. You can edit files in your favorite editor and then compile in that Ubuntu, without VM, without Multi boot.

It is possible with Bash on Ubuntu on Windows, which brings the Terminal (Bash) on your Windows 10. πŸ˜‰

It is called Windows Subsystem for Linux (WSL).

How to get it?

Currently it is in the insider preview builds, if you don’t want to wait for the final update (probably it will take 1 or 2 months)

just install the insider builds, slow ring has also these feature now.

Check out this, how to enable it and use it.

If it asks for username after install just give root for now.

How it gets installed?

After enabling it when you run lxrun /install in cmd it downloads one tar file which has untouched Ubuntu files by Canonical.

and extracts it to C:\Users\Username\AppData\Local\lxss\rootfs.

The tar file is downloaded in %tmp% and gets deleted after extraction.

Let’s do some stuff now,

Most of the tools are working you can apt-get packages (installing apps).

All drives are mounted at /mnt/c, /mnt/d

Compiling using gcc

  • First do apt-get update
  • Now, apt-get install gcc g++
  • Go to the folder where the c files is located by doing cd /mnt/d/file.c
  • gcc file.c
  • ./a.out

Socket programming also works perfectly πŸ˜‰

GCC - WSL bash

If the apt-get update just keep on showing updating package list, check your connection first.

If you are using Bitdefender then make the current adapter trusted in firewall.

Enabling color prompts

If you want color prompts than white text ones

  • cd
  • vim .bashrc
  • Go to line number ~39 and then press i .
  • Delete the # from force_color_prompt=yes
  • Press ESC and then type :wq , hit Enter
  • Restart the Bash on Ubuntu on Windows.

Editing bashrc Color Prompts

Don’t edit any files from lxss directory with any other editor than Notepad, doing that will make the files disappear from WSL.

Other editors erase the extra attributes which are needed for WSL.

Now the most interesting part,

How it is implemented?

It’s not a VM nor a ported bash like other programs available.

In Computers OS has a software part called Kernel which is the intermediate between other softwares and Hardware.

To implement WSL they have a driver called LXSS Core in Windows NT Kernel.

This driver works as kernel for the Linux Subsystem. For communication softwares use SYSCALLS.

When an software from Linux Subsystem communicates with Kernel, the call goes to LXSS Core, if possible it handles the Call on it’s own. Sometimes LXSS Core have to call similar SYSCALL from NT Kernel (like opening a file).

This video from channel9 explains this in detail,

If you want more detail on how it works and how file system and SYSCALLS are implemented, watch all these videos,

Windows Subsystem for Linux: Process Architecture

Windows Subsystem for Linux - Syscall Translation

Windows Subsystem for Linux: File System

More information, updates, report bugs here -

Get it and play around with it πŸ˜€, comment down below the softwares you tried on WSL.


Comments are not enabled on this site. The old comments might still be displayed. You can reply on one of the platforms listed in β€˜Posted on’ list, or email me.

Aditya Deshpande on Wed Sep 14, 2016 00:37 IST

I got Bash on Ubuntu on my Laptop. Thanks for the information.