WSL2 with GUI
Firstly, I want to mention the cover images of medium blogs. It is non-sense bro, it is ridiculous, it is just the reflection of aesthetics instead of functionality among 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 in the end, it should install it. After installation type on cmd
wsl --update
wsl --shutdown
shutdown -r
After restarting both WSL and Windows, open cmd again and type
ubuntu
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
echo $DISPLAY
Now it should all be set.
xeyes