Photo by Tonik on Unsplash

WSL2 with GUI

Abdullah BAŞ


Firstly, I want to mention the cover images of medium blogs. It is nonsense bro, it is ridiculous, it is just the reflection of aesthetics instead of functionality in modern society. Give up on that! This blog will never have a huuugggeeee cover image.

This is the story for the mortals that do not have built-in WSL2 GUI support on their magnificent Windows10.

Ok. Let’s go fellas. We will continue on the cmd terminal as much as we can. First of all, hit Windows+R and then copy and paste the following:

runas /user:Administrator cmd

After opening the cmd type

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestartwsl --set-default-version 2wsl --install -d Ubuntu

It will wait a while, but it should install it in the end. After installation type on cmd

wsl --update
wsl --shutdown
shutdown -r

After restarting both WSL and Windows, open cmd again and type


It will ask for a username and password. Type the following for username and password:

just kidding! Type whatever you want. This is a free bla bla

After setting all that up you should download X-server for exporting the display. This can be done by copy and pasting the following URL into your browser,

After downloading and setting up the X-server you should be able to start a server for display between WSL2 and Windows. Now on ubuntu terminal type. By the way, while opening X server, just click next and yes to all. Default is fine, default is king!

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install x11-apps

Then we need to learn where should we direct our GUI-based tools. It is done by

display=sudo cat /etc/resolv.conf | grep nameserver | cut -f2 -d' ' 
export DISPLAY=$display:0.0

Now it should all be set.