Bash on Ubuntu on Windows

I have been working and developing software on Linux, UNIX and Windows for a while. On the Microsoft platforms I started on MS DOS. Last week I was talking with a colleague and he mentioned that while still in BETA, Microsoft has something called Bash on Ubuntu on Windows. I do enjoy the simplicity and power of the Linux shells. I decided to give the Microsoft BETA software a run.

For your info Bash (from Wikipedia):

“Bash is a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell. First released in 1989, it has been distributed widely as it is a default shell on the major Linux distributions and macOS (formerly OS X). In 2016 it was also made available by Microsoft for use in Windows 10 Anniversary Update, albeit it is not installed by default”.

For your info Ubuntu (from Wikipedia):

“Ubuntu is a Debian-based Linux operating system for personal computers, tablets and smart phones, where Ubuntu Touch edition is used; and also runs network servers, usually with the Ubuntu Server edition, either on physical or virtual servers (such as on mainframes) and/or with containers, that is with enterprise-class features; runs on the most popular architectures, including server-class ARM-based.

Ubuntu is published by Canonical Ltd, who offer commercial support. It is based on free software and named after the Southern African philosophy of Ubuntu (literally, ‘human-ness’), which Canonical Ltd. suggests can be loosely translated as “humanity to others” or “I am what I am because of who we all are”. Ubuntu is the most popular operating system running in hosted environments, so–called “clouds”, as it is the most popular server Linux distribution”.

For your info Windows (from Wikipedia):

“Microsoft Windows (or simply Windows) is a meta family of graphical operating systems developed, marketed, and sold by Microsoft. It consists of several families of operating systems, each of which cater to a certain sector of the computing industry with the OS typically associated with IBM PC compatible architecture. Active Windows families include Windows NT, Windows Embedded and Windows Phone; these may encompass subfamilies, e.g. Windows Embedded Compact (Windows CE) or Windows Server”.

To get to the installation instructions and documentation please go to the following URL:

The software claims to be User Mode Linux and Tools for Windows. The software is not running on a VM. It runs on its own subsystem. The software is still in preview (as of December 08, 2016) or BETA mode.

Before you install the software you need to take care of a reduce number of prerequisites.

  1. Your PC must be running a 64-bit version of Windows 10 Anniversary Update build 14393 or later.
  2. You must turn-on Developer Mode.
  3. You must enable the “Windows Subsystem for Linux (beta)” feature via the GUI or the command-line.
  4. Need to reboot your computer.

At this point what is left is downloading the software. That part is incredibly simple. It takes a few minutes to download and install Bash on Ubuntu on Windows.

  1. Open a command prompt on your computer.
  2. On the command prompt type the following:

C:\> bash

— Beta feature —

This will install Ubuntu on Windows, distributed by Canonical

and licensed under its terms available here:

Type “y” to continue: y

Downloading from the Windows Store… 100%

Extracting filesystem, this will take a few minutes…

Please create a default UNIX user account. The username does not need to match your Windows username.

For more information visit:

Enter new UNIX username: John

Enter new UNIX password: **********

Retype new UNIX password: **********

passwd: password updated successfully

Installation successful!

The environment will start momentarily…

Documentation is available at:


That is all folks!!! I have to admit that the installation was painless.

I entered a couple more commands as illustrated in the following screen capture:

C:\> bash

John@CONDOR:/mnt/c$ pwd


John@CONDOR:/mnt/c$ whoami


John@CONDOR:/mnt/c$ exit



From then on, each time you wish to start the bash shell, you just need to enter the bash command. Each time the software will check and if needed install updates. Clean and simple!!!

To determine what the shell is running at the bash prompt enter:

C:\> bash

John@CONDOR:/mnt/c$ lsb_release -a

No LSB modules are available.

Distributor ID: Ubuntu

Description:    Ubuntu 14.04.5 LTS

Release:        14.04

Codename:       trusty


To find out the type of processor you have installed on your PC, you may use the following:

John@CONDOR:/mnt/c$ cat /proc/cpuinfo

processor       : 0

vendor_id       : GenuineIntel

cpu family      : 6

model           : 44

model name      : Intel(R) Xeon(R) CPU           E5606  @ 2.13GHz

stepping        : 2

microcode       : 0xffffffff

cpu MHz         : 2128.000

cache size      : 256 KB

physical id     : 0

siblings        : 4

core id         : 0

cpu cores       : 4

apicid          : 0

initial apicid  : 0

fpu             : yes

fpu_exception   : yes

cpuid level     : 6

wp              : yes

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes

bogomips        : 4256.00

clflush size    : 64

cache_alignment : 64

address sizes   : 36 bits physical, 48 bits virtual

power management:

processor       : 1


processor       : 2


processor       : 3


processor       : 4


processor       : 5


processor       : 6


processor       : 7



For space reasons, I have removed part of the output. My PC has two CPUs each with four cores. This is exactly what the output of the file indicates.

From the bash prompt one is able to access the NTFS file system used by windows as illustrated by the following screen capture:

John@CONDOR:/mnt/c/sdm/source$ pwd


John@CONDOR:/mnt/c/sdm/source$ ls -al

total 7688

drwxrwxrwx 2 root root       0 Nov 21 10:48 .

drwxrwxrwx 2 root root       0 Apr 28  2016 ..

-rwxrwxrwx 1 root root   17838 Jan 26  2016 cachelistthread.c

-rwxrwxrwx 1 root root   14752 Jan 29  2016 cacheslistthread.c

-rwxrwxrwx 1 root root   17492 Apr 17  2016 casappendtrailer.c


-rwxrwxrwx 1 root root   16379 Feb  8  2016 unlockthread.c

-rwxrwxrwx 1 root root   20782 Jan 14  2016 updatecwmthread.c

-rwxrwxrwx 1 root root   13050 May 11  2015 xmlthread.c


The files in the selected folder are part of the source code for the storage server I developed at work. The server runs on the .NET platform.

John@CONDOR:/mnt/c$ cd Temp

John@CONDOR:/mnt/c/Temp$ ls -l hel*

-rwxrwxrwx 1 root root 8519 Dec  8 14:12 hello

-rwxrwxrwx 1 root root   68 Dec  8 14:05 hello.c

-rwxrwxrwx 1 root root   12 Oct 18 11:08 hello.txt


Seems like we have a file with the name hello.c for which we will display its contents:

John@CONDOR:/mnt/c/Temp$ cat hello.c

#include <stdio.h>

main () {

printf(“main <<< hello world\n”);



The source code contains the typical hello world example. Now, take a look at the following:

John@CONDOR:/mnt/c/Temp$ gcc hello.c -o hello


John@CONDOR:/mnt/c/Temp$ ./hello

main <<< hello world


The program was compiled and executed!!! It is not a Windows but a Linux executable as illustrated by:

John@CONDOR:/mnt/c/Temp$ readelf -h hello

ELF Header:

Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00

Class:                             ELF64

Data:                              2’s complement, little endian

Version:                           1 (current)

OS/ABI:                            UNIX – System V

ABI Version:                       0

Type:                              EXEC (Executable file)

Machine:                           Advanced Micro Devices X86-64

Version:                           0x1

Entry point address:               0x400440

Start of program headers:          64 (bytes into file)

Start of section headers:          4472 (bytes into file)

Flags:                             0x0

Size of this header:               64 (bytes)

Size of program headers:           56 (bytes)

Number of program headers:         9

Size of section headers:           64 (bytes)

Number of section headers:         30

Section header string table index: 27

If you try the same command with a program built on Windows you would get something like:

John@CONDOR:/mnt/c/sdm/bin$ readelf -h sdm.exe

readelf: Error: Not an ELF file – it has the wrong magic bytes at the start


By the way, gcc did not come installed in the Ubuntu distribution. I had to do it by hand. To illustrate the process, I will now install for the first time Git:

John@CONDOR:/mnt/c/Users/John$ sudo -s

sudo: unable to resolve host CONDOR

root@CONDOR:/mnt/c/Users/John# whoami


root@CONDOR:/mnt/c/Users/John# apt-get install git

Reading package lists… Done

Building dependency tree

Reading state information… Done

The following packages were automatically installed and are no longer required:

libfreetype6 os-prober

Use ‘apt-get autoremove’ to remove them.

The following extra packages will be installed:

git-man liberror-perl

Suggested packages:

git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk

gitweb git-arch git-bzr git-cvs git-mediawiki git-svn

The following NEW packages will be installed:

git git-man liberror-perl

0 upgraded, 3 newly installed, 0 to remove and 56 not upgraded.

Need to get 3,306 kB of archives.

After this operation, 21.9 MB of additional disk space will be used.

Do you want to continue? [Y/n] y

Get:1 trusty/main liberror-perl all 0.17-1.1 [21.1 kB]

Get:2 trusty-updates/main git-man all 1:1.9.1-1ubuntu0.3 [699 kB]

Get:3 trusty-updates/main git amd64 1:1.9.1-1ubuntu0.3 [2,586 kB]

Fetched 3,306 kB in 4s (757 kB/s)

Selecting previously unselected package liberror-perl.

(Reading database … 29264 files and directories currently installed.)

Preparing to unpack …/liberror-perl_0.17-1.1_all.deb …

Unpacking liberror-perl (0.17-1.1) …

Selecting previously unselected package git-man.

Preparing to unpack …/git-man_1%3a1.9.1-1ubuntu0.3_all.deb …

Unpacking git-man (1:1.9.1-1ubuntu0.3) …

Selecting previously unselected package git.

Preparing to unpack …/git_1%3a1.9.1-1ubuntu0.3_amd64.deb …

Unpacking git (1:1.9.1-1ubuntu0.3) …

Processing triggers for man-db ( …

Setting up liberror-perl (0.17-1.1) …

Setting up git-man (1:1.9.1-1ubuntu0.3) …

Setting up git (1:1.9.1-1ubuntu0.3) …

root@CONDOR:/mnt/c/Users/John# exit


John@CONDOR:/mnt/c/Users/John$ exit



Just like if you were running Ubuntu on your PS.

If you are a software developer and deal with Linux or UNIX, the Bash on Ubuntu on Windows is something you might wish to add to your toolkit.

If you have comments or questions regarding this or any other post in this blog please do not hesitate and send me a message. I will not use your name unless you explicitly let me know.


Follow me on Twitter: @john_canessa

Leave a Reply

Your email address will not be published. Required fields are marked *