Linux’s Bash shell is coming to Windows, courtesy of a collaboration between Microsoft and Ubuntu-creator Canonical. Type bash into Windows 10’s Start menu, and you’ll be able to instantly get a full Linux command-line environment.
Many developers prefer Linux—and even Mac OS X, which also includes the Bash shell—because of its access to a whole universe of utilities that often don’t work on Windows. Adding the Bash shell to Windows is just another way Microsoft is trying to make Windows more attractive to Linux developers. Remember, Microsoft’s Azure cloud hosting service can run Linux servers, too.
It’s not a virtual machine or container
Before this, you could use Bash on Windows, but through heavy virtual machines or by remotely accessing a Bash session running on a remote server somewhere. There’s also Cygwin, a hacky solution featuring a variety of Linux tools recompiled for Windows. Many people assumed Windows 10’s rumored Linux compatibility would be something along these lines. But they were wrong. It’s more awesome.
This solution will be an app available in the Windows Store, and it will provide a full Ubuntu image that runs in userspace as a program on your desktop. Programs compiled for Linux will just run without even needing to be recompiled for Windows. You can use Ubuntu’s apt-get command to download and install programs, and it’ll just work. Developers can write Bash scripts and run them on Windows. It’s reportedly just as fast as running the same utilities natively on Ubuntu Linux.
This is all thanks to a new subsystem quietly placed into Windows 10 build 14251 back in January. The lxcore.sys and lxss.sys files form the new “Windows Subsystem for Linux (WSL).”
Canonical’s Dustin Kirkland is thrilled about the technology, and explains it this way: “A team of sharp developers at Microsoft has been hard at work adapting some Microsoft research technology to basically perform real time translation of Linux syscalls into Windows OS syscalls. Linux geeks can think of it as sort of the inverse of ‘wine’—Ubuntu binaries running natively in Windows.”
It’s a developer toolset, not a complete Linux system
Microsoft’s solution is surprisingly capable. You get the exact same Linux utilities and they’ll run on your Windows system directly. Although Bash is sandboxed, you can access your file system via the shell and work with the files and folders on your computer. Both your Linux utilities and Windows programs will have access to the same set of files.
But it has some limitations. It will be beta technology when it launches, and not everything will work properly out of the gate.
As Microsoft notes, “This is a developer toolset to help you write and build all your code for all your scenarios and platforms.” It’s not a full Ubuntu virtual machine. You can’t use it to host servers, as you could on Linux. If you need that, you can always install Linux in a virtual machine using Microsoft’s Hyper-V technology, VirtualBox, VMware, or something similar.”
Don’t expect a graphical Linux desktop, either. “We are also only working on command line,” says Microsoft’s Russ Alexander in a video. “This is all about the developer.”
Lastly, these Bash tools won’t be able to interact directly with any Windows tools. You can’t run a Bash command from PowerShell, or a Windows command from within Bash. This means you can’t use Bash scripts to automate Windows commands, unfortunately. Bash command-line tools get access to the same files Windows does, but that’s it!
Here’s how you can get it
This feature isn’t out yet, but it’s on its way. It will be part of the stable version of Windows when Windows 10’s Anniversary Update is released this summer. Until then, you’ll need to be on the Insider Preview track to get the latest unstable version of Windows 10 “Redstone.”
An Ubuntu 14.04 LTS-based Bash application will shortly be added to the Windows Store, followed by a Ubuntu 16.04 LTS-based application once Ubuntu 16.04 LTS launches on April 21.
Want to learn more? There’s a lot of information out there now. Microsoft’s announcement covers the basics and Microsoft’s Scott Hanselman provides some background. Canonical’s Dustin Kirkland provides an explanation targeted at readers familiar with Linux. You can also watch an informative 30-minute video featuring Hanselman, Kirkland, and others who worked on the project.