CS 233 On Your Own Machine: WSL 1 X-Forwarding guide

WARNING: EWS is NOT your own machine. Don’t try to do ANY of this on EWS.

IMPORTANT: You might not have WSL 1! Read through the WSL Intro to be sure.


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.


Step 1: setting up WSL 1 to work with x-forwarding

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.

set $DISPLAY

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


Step 2: setting up Windows 10 to work with x-forwarding

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.

install VcXsrv

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.


You’re done!

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.