Friday, April 15, 2016

Microsoft is adding the Linux command line to Windows 10

Microsoft is reaching out to Linux developers in a way that the company never has before. "The Bash shell is coming to Windows. Yes, the real Bash is coming to Windows," said Microsoft's Kevin Gallo on stage at today's Build 2016 keynote. The announcement received an uproarious applause from the crowd. The new functionality will be enabled as part of this summer's Anniversary Update to Windows 10.
"This is not a VM. This is not cross-compiled tools. This is native," he said. "We've partnered with Canonical to offer this great experience, which you'll be able to download right from the Windows Store." Third-party tools have enabled this sort of thing for years, but a direct partnership between Microsoft and Canonical should offer even more flexibility and convenience for developers who prefer using these binaries and tools.
More importantly, it represents Microsoft's refreshing stance on open-source development. VP Terry Myerson teased "more coming soon" in regards to other possibilities signaling a modernized and extremely open Windows 10. This blog post by Microsoft's Scott Hanselman offers a deeper explanation of the move. "This is brilliant for developers that use a diverse set of tools like me," he said. "This is a genuine Ubuntu image on top of Windows with all the Linux tools I use."

Update: Microsoft has posted a very in-depth video covering Bash on Windows, which we've embedded at the top of this article. It should answer just about any question you might have.

Windows 10's Bash shell can run graphical Linux applications with this trick

Microsoft said it wouldn’t support graphical applications in Bash on Windows. But enterprising geeks like w2qw on Reddit have already figured out how to run graphical applications with Bash on Windows 10. The underlying code is much more capable than Microsoft initially let on.

Install an X server

This is possible because the Bash shell for Windows is more than just a shell. Microsoft built an entire “Windows Subsystem for Linux” that allows Windows 10 to natively run Linux applications, even graphical ones. Install Bash for Windows 10 and you’ll actually have a complete operating system layer for running Linux applications and a full Ubuntu userspace environment—that is, everything above the Linux kernel.
The only missing piece is an X server that allows those graphical applications to appear on your Windows desktop. This is basically the same technique people would use to run graphical Linux desktop applications over a network.
The Xming X Server for Windows works well for this, although there are other X servers for Windows and they should also work. Download and install it on your Windows 10 PC to get started. You can just use the default settings and it’ll work fine. Launch Xming and it will appear in your system tray, running in the background and waiting for you to launch a graphical Linux program.
Windows 10 running Linux desktop applications. w2qw
This is Windows 10 running Linux desktop applications.

Launch applications from Ubuntu’s Bash shell

You’ll now need to install a graphical application, which you can do with the standard apt-get command in the Bash shell environment. The apt-get command has access to Ubuntu’s entire software repositories, so you can use it to install graphical applications without any additional tweaks.
For example, to install the Linux version of Firefox from Ubuntu’s repositories, you’d just run the following command:
apt-get install firefox
Once you’ve installed the program, you can specify the X server and then launch the application. For example, to launch Firefox, run the below commands. (To launch another graphical application, just specify its name instead of “firefox.)”
export DISPLAY=:0
Assuming you’re running an X server like Xming on your Windows PC, the graphical application should run. It may not run as speedily—applications can’t use direct rendering to run on your hardware directly.
This is currently a bit unstable. Many applications I tried were unable to run reliably. Some people report better success. But bugs are no surprise, as the Windows Subsystem for Linux is beta and this is its first release. As Microsoft improves the underlying code, applications—even these graphical applications—should work better and better over time.