This guide will walk you through how to set up X-Forwarding for Windows Subsystem for Linux version 1. This guide has been tested on Ubuntu 20.04 LTS running on WSL 1. If you have WSL 2, use the WSL 2 guide instead, or downgrade to WSL 1. If you aren’t sure which version of WSL you have, or if you do not have WSL installed, read through the WSL Intro.
You will need to make a small configuration change to your installation of Ubuntu before x-forwarding will work. Perform the following step on the bash prompt in WSL.
Running the following command will make it so Ubuntu knows how to open a connection to VcXsrv
, the program that will allow you to see windows opened on WSL.
echo "export DISPLAY=:0" >> ~/.bashrc
After running this command, you will need to reload the .bashrc
file like so:
. ~/.bashrc
This step will set up your Windows installation to accept GUIs being shown by WSL 1. Perform the following steps on Windows, not in WSL.
This program will act as a virtual display for WSL to show all of its graphics on. In short, it needs to be running for you to see any GUIs from WSL.
You can download VcXsrv
from sourceforge. Once VcXsrv
is installed, the program used to launch it will be called XLaunch
, which you should be able to find from your Start menu search bar. When starting XLaunch
, you can click through all the prompts and leave them at their default settings. You need to have VcXsrv
running any time you want to use a graphical app in WSL.
To check if x-forwarding is working, launch VcXsrv
, open WSL, and run the gtkwave
command. If everything has gone as planned, you will see a window open.