How to run Linux GUI apps on the Windows Subsystem for Linux ? (WSL 1/2)

John Doe
Active Developement
3 min readAug 26, 2022
Run Linux GUI apps on the Windows Subsystem for Linux

You probably already wanted to start a program from your WSL. In example above your favorite Git client (SmartGit, Kraken, etc).

Microsoft knows this need and released recently a compatibility on Windows 11. Unfortunately, this not optimized as we would except …

Some known issues to Windows 11 GUI implementation :

  • Apps window are not well sized/proportioned
  • A majority of app crashes after several hours (this is an issue as you will need to restart all opened wsl and sometimes restart completely your computer)
  • Not compatible with old Windows version (10, 8, 7)

This thread concerns people which…

  • wants to run a GUI program on WSL instance
  • faced of GUI crashes on Windows 11 on her WSL instance

I tried myself to reproduce what the Windows 11 has brought to WSL. This means that the GUI output must be sent to a local displaying server.

Windows 11 uses Remote Desktop to handle it. I find a great tool named “VcXsrv Windows X Server Files” which it is more efficient and compatible with all Windows version.

How to do ?

To start with the tool, you need to have atleast a WSL instance on your computer.

Install and configure VcXsrv.

You need to install “VcXsrv” service below : https://sourceforge.net/projects/vcxsrv/files/vcxsrv/1.20.14.0/

After the installation run the application called “XLaunch” a new window should appear on your screen:

You need to choose “Multiple windows” mode, and set Display number to “-1”.

Next step is to setup “Client startup” — please choose “Start no client” option to do so. At the “Extra settings” step, select “Clipboard” and “Disable access control” options like on my screen:

Go to the end of steps, now VcXsrv is started and minimized to your window tab.

Prepare WSL instance to display GUI on your local displaying server.

You need to start a WSL instance, in the example I choose Ubuntu but you can go with Debian or wathever.

Update the packages in your distribution:

sudo apt update

Configure the DISPLAY variable:

You must edit the .bashrc under your current profile and add the DISPLAY variable. This is representing the IPv4 in the current network of your displaying server. It is located at /home/YOUR SESSION USERNAME/.bashrc

Append to the file the following line:

export DISPLAY=$(route.exe print | grep 0.0.0.0 | head -1 | awk '{print $4}'):0.0

Save the file modification and restart your WSL instance by typing this command in Windows cmd:

wsl --shutdown

Now if you do “echo $DISPLAY” inside your WSL instance you get this output:

echo $DISPLAY
192.168.69.153:0.0

Required only for Windows 11 users

Windows 11 implements its own solution with Remote Desktop service — it seems to be not stable enough. I show you how to temporary disable the default behavior.

https://github.com/microsoft/WSL/issues/8084

You just need to edit/create .wslconfig file located at your windows user root folder (C:\Users\MyUsername) and add this:

[wsl2]
guiapplications=false

Test the GUI displaying system

For testing your new display system, you just need to install some GUI like nautilus on your WSL instance:

sudo apt install nautilus -y

And run it :

nautilus &

Taaaadaaaaam !

Nautilus GUI now appear

Written by Valentin VOYNIER with all of my ❤.

--

--