Run Linux Desktop Applications on Windows 10 using Bash

If you’re a developer working with both Linux and Windows, you can use Bash shell on Windows 10 to run Linux commands. I use it all the time for Git or Python. But did you know that Bash shell on Windows can run native Linux desktop applications like Gedit, Kdiff3 or even Xfce4?. As strange as this may sound, the answer is YES 🙂

1. Install Bash for Windows

If you’ve never heard about the Windows Subsystem for Linux, then I encourage you to check it out. Installing Bash on Windows 10 is covered in great detail in this article.

2. Install X-Server on Windows

X-Servers are used to render Linux programs that run on a different machine. Because the Windows Subsystem for Linux does not have one by default, we need to install it ourselves. There are a couple of free X-Server applications available, but I use VcXsrv. Download, install and launch this application. A tray icon should appear when the X-server is running.

VcXsrv tray icon

VcXsrv tray icon

When launching VcXsrv, the Windows Firewall pop-up will appear, asking you to allow VcXsrv through the firewall and make it available to other computers. Uncheck all boxes. You will only need the X-Server on the local machine.

Do not allow VcXsrv through the Firewall

3. Configure Bash to render desktop applications

First, open the Ubuntu bash shell and execute a global update.

sudo apt-get update

After the update is complete, we need to redirect rendering to the X-Server we installed on Windows. To achieve this, simply add the following line to ~/.bashrc

echo "export DISPLAY=localhost:0.0" >> ~/.bashrc
source ~/.bashrc

4. Install and run a Linux desktop app

With everything in place, we can now install a Linux desktop application. For this post, I chose to install Gedit, the famous Linux text-editor. When you launch desktop applications on bash, the experience might not be as smooth as in Windows, but the programs are certainly usable 😉

sudo apt-get install gedit

Gedit running on Windows 10