March 30, 2016 11:57 am

Run Bash on Ubuntu on Windows

Since we started planning and building Windows 10, we’ve been talking to a lot of you about what you would like to see in Windows to make it a great place for you to build awesome apps, sites and services for all platforms and all devices.

Many of you told us that working with open-source tools on Windows is often a struggle and that you would like Microsoft to make it easier to use these tools on Windows.

Based off your feedback we’ve done a couple things: First we made investments that improve cmd, PowerShell, and many other command-line tools and developer scenarios. Second we decided to grow our command line family by adding real, native Bash and with it support for Linux command-line tools which run directly on Windows in an environment that behaves like Linux!

To accomplish this, we built new infrastructure within Windows – the Windows Subsystem for Linux (WSL) – upon which we run a genuine Ubuntu user-mode image provided by our great partners over at Canonical, creators of Ubuntu Linux.

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.”

— Mark Shuttleworth, founder of Canonical

The result is that you can now run native Bash on Ubuntu on Windows!
1_bash

You can now 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. You can also access your Windows filesystem from within Bash allowing you to work on the same set of files using your preferred Windows tools or Linux command-line tools:
2_bash

Caveat Emptor (Buyer Beware!)

While we’re excited for you to try out this new technology, which will first become available in Windows 10 “Insiders” builds after the Build conference, we want to be clear about a few things:

First, this is the first time we’re releasing this technology – it’s marked as beta for a reason: We know that there are some rough edges and that some things will break! Do not expect every Bash script and tool that you run will work perfectly – there will be gaps. But by trying out this feature, you’ll help us figure out what we need to work on in order to greatly improve our reliability, coverage, and reach.

Second, while you’ll be able to run native Bash and many Linux command-line tools on Windows, it’s important to note that 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. For running production workloads on Ubuntu, we have some great solutions using Azure, Hyper-V, and Docker, and we have great tooling for developing containerized apps within Windows using Docker Tools for Visual Studio, Visual Studio Code and yo docker.

Third, note that Bash and Linux tools cannot interact with Windows applications and tools, and vice-versa. So you won’t be able to run Notepad from Bash, or run Ruby in Bash from PowerShell.

But wait, there’s more!

Existing command-line tools are now greatly improved thanks to investments made in the Windows Console. We’ve significantly improved rendering performance, added support for more VT-100 sequences, and how it handles complex text layout. We’ve also made some key improvements in how the Console handles High-DPI screens.

These improvements directly benefit cmd prompt, PowerShell, new tools like Bash, the new Windows Docker client, and many other existing Microsoft and 3rd party command-line tools.

Related Build 2016 Content

If you’d like to learn more, you can watch Kevin Gallo’s keynote announcement and demo of running Bash on Ubuntu on Windows at Build 2016.

Also, Rich Turner and Russ Alexander recorded a Build 2016 session introducing and demonstrating Bash running on Ubuntu on Windows.

We look forward to working with you to improve the Windows command-line tools and console: Please continue to suggest features etc. via our Windows Command-line UserVoice portal and stay tuned for lots more news on our new command-line blog. Also, visit our new command-line documentation portal for content and links to resources.

Updated March 30, 2016 12:54 pm

Join the conversation

  1. And I was all excited, but this is a problem…

    “Third, note that Bash and Linux tools cannot interact with Windows applications and tools, and vice-versa.”

    I hope that this is a temporary restriction. I’d like to be able to use bash to create scripts to automate tasks for me. In the past using Cygwin, I’ve done similar things, running commands in SQLCMD to make the same updates to several different databases.

    Without this ability, then this is just a fun plaything, probably not something I can use to benefit my daily work very often.

    • Great feedback Chris.

      You state that you want to invoke Windows tools within your Bash scripts and workflow. What kind of tools, specifically, would you find useful? Could you give us an example workflow that would employ tools on both the Bash and Windows sides?

      Not sure if it came across during the keynote, but you can access your Windows filesyste, from within Bash so could use Windows tools and Bash tools to work on the same set of files if you need to.

    • To add on to what Rich said, bi-directional interop with Windows & Linux processes is something we are very interested in enabling. However, we want to know the specific scenarios you have in mind so we make sure to design the feature appropriately.

  2. Echoing Chris here. Until there is interplay with Windows apps and file systems completely, this is not that different from VM running Ubuntu really (other than some speed-up perhaps).

    It will be interesting to see how MS enables command/IPC equivalents between the two. Looking forward to exploring more.

    • Hey Suman.
      Note that you can access your local machine’s drives from within Linux – they’re mounted under /mnt. For example, your C: drive will be under /mnt/c/.

      This means that you could use VSCode to edit your Ruby source code sitting on your Windows PC and then switch to Bash to build and run using Rake/Ruby. This is particularly useful if any of your Ruby Gems contain Linux dependencies; they should run within the Bash environment, whereas they’d fail when run in Windows.

      As I mention above to Chris, we’re interested in what kind of process interop you’d like to see in the future. What Windows apps would you like to call from Linux, and vice versa?

      Rich.

      • Hey there Rich, great work!
        Continuing on this topic about interop, one thing that comes to mind is integrating git in some tools (like VS Code running on windows). If we don’t have that interop, we’d have to install both git from apt and git-scm.com in order to be able to use it from bash and from VS Code – if that’s the case, then it’s better to use MSYS2 or Cygwin, as those work from the terminal and from windows itself.
        Also, if that interop was working, I would be able to use bash vim to work on my win32 projects, by running cl from vim and compiling from there. Without that, again, I’d have to install both ubuntu’s vim and a win32 compiled vim in order to work on win32 projects.

        Nevertheless, I think this is a big step in a great direction, looking forward to testing this. Do you know more or less when this feature will be available to Windows Insiders?

    • Thanks Liam – I’ll forward your comment to the team :)

      Note that some of our content locations etc., are still waking up and should be live before long.

      Rich.

  3. Hi,

    Really excited by this news and I have one question:

    Will bash ne compatible with lumia 950 XL with a display dock connected si I can clone git repo and édit locally with emacs/vim? Lumia 950 XL with display dock lack Visual Studio Code compatible and this would ve a good alternative :)

    Thank you

  4. Which Windows Insider ring would be the most secure that would still get Bash on Ubuntu on Windows most soon?

  5. Pretty exciting stuff. Continuing on the point about interop, it would be nice if Windows GUI applications are able to run Linux command line tools with arguments determined at runtime and then capture the resultant output. The use case that I would like to see supported is the ide-haskell plugin for the Atom editor being able to run ghc-mod (a linux command line tool) with a path to a file as an argument (this is a temporary file generated by the plugin from the current state of the editor, the source code file, cursor location for type inference & etc.) and then read the output. In this use case I think being able to read the buffered output on the termination of the process is adequate (instead of having access to the output as a stream) as the process is short-lived.

  6. POSIX subsystem (Psxss), Interix, Services For Unix (SFU) and Subsystem for UNIX-based Applications (SUA) redux?