Before we get on to see how to run Bash on Ubuntu on Windows, here’s a little bit on the amazing step by Microsoft to integrate user mode Linux and its tools into Windows OS. Who would have thought one would be running native Bash directly on Windows.
At the start of Windows 10 cycle, Microsoft opened an user-voice page and started a conversation about the Windows command-line. They asked the community what they like about Windows command line and what features they would like to see in Windows command-line.
Many in the community replied that they would like to see some improvements to Windows Command line. Some others said they would like to bring Linux/Unix tools to Windows. As working with open-source tools on Windows is often a struggle users said that they would like Microsoft to make it easier to use these tools on Windows.
Listening to the community voice, Microsoft first improved CMD, PowerShell and many other Windows command-line tools and secondly did what was unbelievable few years back. Microsoft decided to add real, native Bash and with it support for Linux command-line tools which run directly on Windows in an environment that behaves like Linux! Its not any VM but the real Linux on Windows.
Windows Subsystem for Linux
For this Microsoft built new infrastructure within Windows – the Windows Subsystem for Linux (WSL) upon which genuine Ubuntu user-mode image is run provided by its partner Canonical, creators of Ubuntu Linux.
This will make Windows developers far more productive and use these tools much more seamlessly. And this will be a long term solid, reliable and stable solution.
Here is what Mark Shuttleworth, founder of Canonical said:
“In our journey to bring free software to the widest possible audience, this is not a moment we could have predicted. Nevertheless, we are delighted to stand behind Ubuntu for Windows, committed to addressing the needs of Windows developers exploring Linux in this amazing new way, and are excited at the possibilities heralded by this unexpected turn of events.”
What is Bash in Linux
For those who do not know, Bash or Bourne Again shell is a standard GNU Linux Shell program.
According to Wikipedia, Bash is a Unix shell and command language for the GNU Project as a free software replacement for the Bourne shell. it has been distributed widely as the shell for the GNU operating system and as a default shell on Linux and OS X.
Run Bash on Ubuntu on Windows 10
Starting with Windows 10 Insider Preview Build 14316, Windows Subsystem for Linux has been provided. Starting with this build, one can run native Bash on Ubuntu in Windows. This was first announced at Build 2016. This is how one does it.
First one has to turn on Developers Mode from
Settings > Update & Security > For Developers. Check the Developer Mode radio button. And search for “Windows Features” , choose “Turn Windows features on or off”.
Select “Windows Subsystem for Linux (Beta)” . Press OK.
It will start searching for the required files and starts applying changes. Once done, one has to reboot to finish installing the requested changes. Press Restart now.
Once rebooted, from the Start button right click and open Command Prompt (Admin) or PowerShell.
Type “bash” at command prompt and Enter. You’ll get a message “This will install Ubuntu on Windows, distributed by Canonical and…” . Type “y” to continue. Press ‘y’ and your download from the Windows Store starts. After downloading, it will start extracting the filesystem. This will take some time, so be patient.
After sometime you’ll get the message “Installation Successful! The environment will start momentarily…” and you’ll be at the Bash prompt.
From here on , now you can run Bash scripts, Linux command-line tools like sed, awk, grep and you can even try Linux-first tools like Ruby, Git, Python, etc. directly on Windows. One can also access Windows filesystem from within Bash.
After installing, it’ll also be listed in the App list. So that one can open All apps and click on “Bash on Ubuntu on Windows” to open Bash prompt.
Remember, this is a developer toolset to help you write and build all your code for all your scenarios and platforms. This is not a server platform upon which you will host websites, run server infrastructure, etc.
As this being one of the coolest thing to happen to Windows, one must give it a try if you are interested about Linux, Ubuntu on Windows.
You can also check out this video tutorial by Scott Hanselman:
Visit his blog for additional information.