How to do GUI Applications in Windows Subsystem for Linux
Everyone says you can't do GUI applications in Windows Subsystem for Linux (WSL), but did you know you really can?
In fact, you can even get a full X Windows session with WSL. I'm going to show you how.
There are two ways to do this, you run individual X applications, or you can get an entire X Windows desktop.
Launch X Windows Applications
This method is easiest and will allow you to run individual applications with ease.
You will first need an X Windows client, fortunately, there is a free option called VcXSrv.
Once you install VcXSrv, this will act as an X Server for hosting applications.
Launch the application and select the following options to start up the X Server host.
Note the disable access control on the third screenshot. You can do access control but it is a bit more complicated.
In your Linux distribution add the following line to the end of your .bashrc file.
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0
You can either reboot your WSL instance or run this command in the shell as well to put it in your current session.
Let's install an X Windows application to test it.
sudo apt install xterm
Then just run xterm
Run a full X Windows session.
Install Xfce4
sudo apt-get -y install xfce4 && sudo apt-get -y install xubuntu-desktop
This step will take a long time, it will install a full X Windows desktop.
Once finished, you can just run startxfce4
to start the desktop.
While this works well and good, I'm going to show you an even better way to get a full desktop.
Introducing xRDP
Install xRDP Server
sudo apt-get -y install xrdp
Configure xRDP
echo xfce4-session > ~/.xsession
Restart xRDP service
sudo service xrdp restart
Find your IP
ifconfig | grep inet
You do need your IP as you can't use localhost as Windows already has RDP built-in.
Hit F8 and type in "Remote" and you should see
This method will perform a lot better for a full X Windows session, but I think you will be surprised at how well it actually performs.
While WSL doesn't support static IP, there are some tricks you can use to make it easier to acquire the IP. One option is using this service to automatically update it.
While there are other options like a full Virtual Machine if you want to run X Windows, this is a great option if you want to experiment or have a few quick things you want to do.
Once I found xRDP, I was a happy camper. I've never played with WSL though ... so now I need to find some time to explore.
Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!
Please consider supporting our funding proposal, approving our witness (@stem.witness) or delegating to the @stemsocial account (for some ROI).
Please consider using the STEMsocial app app and including @stemsocial as a beneficiary to get a stronger support.
At this point I think you can just muster the courage and install Linux somewhere on physical hardware. 😂😂😂