Running Linux GUI with WSL

WSL is great for running Linux shell on the Windows machine. You have access to the awesome Linux tooling and apps that every developer loves.

Problem arises when we want to run an app that requires graphical interface. Currently WSL does not support any graphical interface officially but as always there are some ways to bypass the limitations. As far as I am aware, this can be achieved in two ways:

  • Install X Sever for Windows
  • Use remote desktop (e.g. XRDP)

I have tried both solutions and none of them is perfect. Remote desktop connection is laggy and adds a lot of overhead but it is still more reliable and effective than trying to use the X Server (e.g. Xming or VcXsrv). X Server solution requires more fine tuning, fiddling with the configuration and takes more time to setup. It also often crashes with very exciting traceback that hurt your eyes.

Setting up XRDP

XRDP is an open-source Remote Desktop Protocol server that provides a graphical login to remote machines. Windows machines have it already preinstalled as a Remote Desktop Connection app. In Linux based systems it must be installed.

    $ sudo apt-get update && apt-get install xrdp

After XRDP is installed, a graphical interface for Linux must be installed. I found online that people start with the lightweight desktop environment xfce4. It doesn't look amazing but it does the job.

    $ sudo apt-get install xfce4 

After all required components are installed, it's time for the configuration. First xfce4 must be set as the default X server. This is achieved by creating the ~./xsession file and adding the custom interface executable name. For more information check the CustomXSession man page.

    $ echo "xfce4-session" > ~/.xsession

Fine tunning the XRDP

By default XRDP will run on the 3389 port. If you want to customize it, you can do that in the config file.

    $ sudo vim /etc/xrdp/xrdp.ini


After we're happy with the setup, we need to start the XRDP server.

    $ sudo service xrdp start
Start XRDP

Server should start and you will be able to see it running.

Check XRDP is running

Check the IP of your local Linux server by running:

    $ hostname -i

This will print out the IP you should connect to. Copy the printed output and combine with the port number the XRDP is exposing. Now start the Remote Desktop Connection app in Windows and connect to the Linux.

Remote desktop connection
Remote desktop connection to Ubuntu