Friday, April 15, 2016

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.