I searched around, and currently there are two methods suggested; installing an enhancement for Windows Subsystem for Linux and installing an XServer.
I want to know which method is the most hassle-free (easy to install AND to use), and which one is less memory-heavy.
I just want Synaptic and CMake. Why couldn't that be a builtin feature?
VcXsrv
I chose to use
VcXsrv
in WSL (Windows 10 Subsystem for Linux). I recommend everyone do their research betweenxming
(the accepted answer) and VcXsrv before selecting one or the other for Graphical User Interface (GUI) support in Windows 10 Ubuntu 16.04.Installation
Installation is straight forward. As of March 17, 2019 you can simply accept the defaults. If you want to call
gedit
from within your Bash Shell / Terminal you need to edit~/.bashrc
and insert this line:What can you do after VcXsrv is installed?
I was able to run:
... to install GUI desktop software. This then allowed me to run
gedit
andnautilus
. Also I was then able to install specific GUI applications through the CLI (Command Line Interface) usingapt
orapt-get
commands.When I want to try many of my Ubuntu bash scripts within WSL VcXsrv must be installed so
zenity
andyad
x-windows dialog boxes are displayed for user input.As others have noted GUI within WSL is not perfect and you can expect to spend time problem-solving some issues. Also some GUI software simply won't work in WSL.
Setup notes
I modified
/etc/environment
to tweak GUI drop down menus:/mnt/e/bin
is unusual path because it is where I store scripts used in both Windows 10 dual boot WSL and Ubuntu 16.04 dual boot. Most users would not include this on their machine.The short answer is you can not as WSL does not yet support this function. WSL is not a full Linux installation with a Linux kernel, it allows you to run some native linux commands / binaries on a Windows (Microsoft) kernel and has limitations.
See https://github.com/Microsoft/WSL/issues/2356
You can, however, install a 3rd party X server, such as xming, and ssh into your WSL.
https://virtualizationreview.com/articles/2017/02/08/graphical-programs-on-windows-subsystem-on-linux.aspx
I did not copy that tutorial here as it is fairly ubiquitous (X over ssh) and I would expect some apps simply will not work even with this technique.
I've had a very positive experience with VcXsrv on Win 10 Bash on Ubuntu on Windows (Ubuntu 16.04 Xenial x86_64 Linux 4.4.0-17074-Microsoft). I did not focus on running Unity desktop as it is useless and resource consuming. I just simply ran apps from bash in GUI mode from Windows10 desktop using XServer.
Install VcXsrv from here on Sourceforge
Run the VcXsrv app directly, do not launch XLaunch. You should see
localhost:0.0 - 0 clients
when you hover over the icon on Win10 TaskbarOpen Ubuntu Bash:
(results in localhost@localhost:/mnt$)
(localhost@localhost:/$ meaning this commands brings you to the beginning of the hard-drive as far as WSL can see...)
(this will install "dbus" to create virtual connector for GUI, "Synaptic Package Manager" and "Nautilus" file explorer for unity-desktop
(When
session.conf
opens in vi editor)Press i to enter insert mode and add
than add:
Press ESC when you are done editing file and
:wq
to save the file.Run these commands and check their output:
ubuntu-desktop
,unity
,ccsm
,compiz
and try to run Unity Desktop for Ubuntu. I did not try to set the "Steam" because I am still suffering rrying to run "Unreal", Good luck :)If someone knows how to run
gnome-terminal
on XServer instead of XTerm please share...P.S
You can add VcXsrv as a Win10 bootable
To max your sources with "Steam" as specified in original post, tune your Windows a little for network package management (to lower latency) and CPU/GPU prioritization to make a Win10XBox… :)
Although you will run "Steam" under "Unix" the shell is still "Windows" which allows you to launch "Steam" on "Unix" …
Tcp Prep:;
In regedit:
Here you need to go through the list of sub-keys to locate the network adapter entry that is used to connect to the Internet. If you are using DHCP, you need to look for
DhcpIPAdddress
entry (with system data values NOT:0.0.0.0
) to find the correct adapter.Once you have located the correct key right-click it and select New > Dword (32-bit) Value.
Name it TcpFrequency and click ok.
Double-click the value afterwards and set its Decimal value to 1. (To restore the default setting, change the value to 2 or delete the key) Now navigate to the following key:
HKEY_LOCAL_MACHINE\Software\Microsoft\MSMQ
Right-click on the key again and select New > Dword (32-bit) Value.
Name the new parameter TcpDelay
Double-click it afterwards and change its Decimal value to 1. (To restore the key at a later point in time change it to 0 or delete the key)
Nagle’s Algorithm
Nagle’s algorithm combines several small packets into a single, larger packet for more efficient transmissions. This is designed to improve throughput efficiency of data transmission. Disabling “nagling” can help reduce latency/ping in some games. Nagle’s algorithm is enabled in Windows by default. To implement this tweak, modify the following registry keys.
For the
{NIC-id}
, look for the one with your IP address listed; under this{NIC-id}
key create following DWORD value:Note:
Network Throttling Index
Windows implements a network throttling mechanism, the idea behind such throttling is that processing of network packets can be a resource-intensive task. It is beneficial to turn off such throttling for achieving maximum throughput.
To implement this tweak, run regedit and modify the registry
Under SystemProfile, create a DWORD value and name it to NetworkThrottlingIndex then set its Hexadecimal value to ffffffff for gaming and max throughput: ffffffff completely disables throttling.
System Gaming Responsiveness (Not so sure about this one :)
Multimedia streaming and some games that uses “Multimedia Class Scheduler” service (MMCSS) can only utilize up to 80% of the CPU. The “Multimedia Class Scheduler” service (MMCSS) ensures prioritized access to CPU resources, without denying CPU resources to lower-priority background applications.
To implement this tweak, run regedit and modify the registry key
From there, create a new DWORD and name it to SystemResponsiveness set its decimal value to 00000000 for pure gaming/streaming.
In the same Registry hive as the above tweak, you can also change the priority of Games. To implement this tweak, go to
and change the following registry values:
All cheers for "unknown" (pardon me was a while since I copied your directions) author of this Windows=Xbox tweak...
PPS: If XServer fails on what you would like to do try to find the workaround with Docker.
Microsoft announced the green light for WSL 2 GUI: https://devblogs.microsoft.com/commandline/the-windows-subsystem-for-linux-build-2020-summary/#wsl-gui
Even though a full GUI desktop environment is not ‘officially’ supported by Microsoft, it can work.
Turn Windows features on or off
Enable Windows Subsystem for Linux
Restart Computer
Launch Microsoft Store
Search for Ubuntu
Select Ubuntu 18.04 under Apps
Click Get
Launch Ubuntu and wait for install
Set username and password
Run the following Commands:
Create and modify .xsession
Add text:
Save and exit vi
You will need a second account on Ubuntu
Modify startwm.sh
Comment out the bottom two lines
Add text:
Save and exit vi
In Windows, restart Ubuntu and run:
In Windows run mstsc.exe
Computer: 127.0.0.1:3390
Leave username blank
Connect
Session: Xorg
username: remote
password: password
Enjoy xfce!
When done, close the remote desktop connection
Return to the Ubuntu command line
Based on my research, wsl was originally not designed for GUI users. However, we can install an X-server from the third party to display GUI. I have tested that VcXsrv with some proper setup can be used to display Debian Linux-desktop.
I think my approach works smoothly to display mate-desktop (GUI) on windows subsystem Linux Debian. I have made a video on how to install and display mate-desktop (GUI) on wsl Debian from scratch. Link: https://youtu.be/QjogEWudpaM
The installation of the mate-desktop on Ubuntu is slightly different.
Step 1: install wsl
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Step 2: install a Graphic user interface, such as mate desktop.
For Debian User:
sudo apt-get update
, hit enter.sudo apt install task-mate-desktop
, hit enter.OR for Ubuntu User:
sudo apt install tasksel
, hit entersudo apt update
, hit entersudo tasksel install ubuntu-mate-desktop
, hit enterStep3: Install the X server in windows 10. I used an open-source server called VcXsrv. It can be downloaded from https://sourceforge.net/projects/vcxsrv/.
Once the installation is completed:
open XLauch in windows 10
perform the following setup:
"One large window"
Display number: 0
next
Start no client
next
finish
Step 4: setup in Linux console:
type
export DISPLAY=:0
type
export LIBGL_ALWAYS_INDIRECT=1
(maybe this commend is not required)Step 5: Display mate-desktop GUI:
type
mate-session
for Debian usertype
mate-session
orlightdm-session
for Ubuntu userIf you get confused about my description, you can check my youtube videos Install GUI (mate desktop) to Microsoft Windows Subsystem Linux.
According to the official documentation:
Prerequisites
You will need to be on Windows 11 Build 22000 or higher to access this feature.
Installed driver for vGPU
This will enable you to use a virtual GPU (vGPU) so you can benefit from hardware-accelerated OpenGL rendering.
Installing GUI applications on WSL.
Assuming, you've satisfied all the prerequisites and have already installed WSL, you've to now update WSL.
Open a PowerShell window, by clicking Start → typing "Power Shell" → right-clicking Windows PowerShell → Run as administrator.
Update WSL:
You will need to restart WSL for the update to take effect:
You're now ready to begin using GUI apps on WSL.
NOTE: Support for GUI apps on WSL does not provide a full desktop experience. It relies on Windows desktop, so installing desktop-focused tools or apps may not be supported.
Install any GUI application, for example, for installing gedit, run:
For launching gedit, run:
References: Official Documentiation
If you want an effortless off the shelf solution, use MobaXTerm. It's a great, multitabbed terminal emulator with direct support for WSL, and has a built-in optimized X server. I use synaptic all the time on Moba. Even RStudio.
So the question asks for three "scoring" criteria for techniques for running Linux GUI apps in WSL:
I'm going to add to that:
"Easiest" is a matter of opinion, to some degree, but I'm happy to provide mine. In general, I think it's more important to understand all the available options and decide which one works for your needs.
At this point in time, there are at least three techniques for running Linux GUI apps under WSL:
xrdp
and a desktop manager in Ubuntu/WSL and connect via the Windows Remote Desktop ConnectionI'll cover each below.
WSLg
While not an option when this question was originally asked, Linux GUI apps are now supported out-of-the-box on WSL2 with Windows 11 using WSLg.
Whether or not upgrading to Windows 11 is easy (or even possible) will depend on your hardware. Windows 11 has more stringent hardware requirements than Windows 10, of course.
If you upgrade from Windows 10 to Windows 11, you need to update your WSL installation using:
... then restart.
This will bring in the WSLg feature along with the latest kernel and other updates.
If you are on a fresh install of Windows 11, use:
This will (along with a reboot) install:
GPU acceleration is also supported in WSLg using updated drivers. Pulse Audio is also preconfigured.
The WSLg architecture utilizes a read-only "system distribution" based on the CBL-Mariner distribution that Microsoft also uses for its Azure Cloud Services. This distribution is preconfigured to run Wayland/XWayland, with the sockets shared via the internal WSL network and symlinked to the appropriate files (e.g.
/tmp/.X11-unix
) for each WSL2 distribution you install (e.g. Ubuntu).The
DISPLAY
andWAYLAND_DISPLAY
variables are preconfigured by the WSL/init
(PID 1) process on initial startup.Note that WSLg only works for WSL2, not WSL1 instances.
WSLg Summary and Scoring:
Ease of install: Depends on if you can upgrade to Windows 11
Ease of use: Excellent
Flexibility: Most flexible in some ways -- Runs Wayland/Weston/Xwayland. Can run a Weston-on-Weston implementation to run a full screen desktop if desired.
Least flexible in other ways -- Only runs under WSL2 and Windows 11. Both other options can support WSL1 and Windows 10.
Memory Consumption: Short answer -- Around 213MB to run
xterm
. We can assume the majority of that is from the WSLg infrastructure. Regardless, I also tested the other two scenarios below withxterm
, so it's memory usage is the rough constant in these measurements.See footnote at end of this post for more information on the memory usage of WSLg. Note that this includes Wayland, Xwayland, and Pulse Audio support with this memory footprint. The other two options listed below do not include Wayland or Pulse Audio.
Performance: Highest once it is loaded - GPU accelerated. glmark2 of 666 on my system (nVidia 2070 Super), which sounds low, but remember that this is being composited onto the Windows desktop. It's almost double that of VcXsrv and around 4 times that of xrdp.
However, note that there is an initial delay while the system distribution is copied and started the first time you launch any GUI application in a WSL2 session. On my, high-midrange performance system, this delay is about 5 seconds. Additional GUI application launches after that are sub-second.
xrdp
For those who cannot upgrade to Windows 11, or for those who still need WSL1 support, there are still two good options. The first, and my preferred method, is to run
xrdp
in Ubuntu and simply use Microsoft's Remote Desktop Connection with something lightweight such as Xfce4.In /etc/xrdp/startwm.sh, comment out the last two lines (that mention Xsession) and add:
Start xrdp with:
And that's it -- You should be able to connect to your WSL Desktop using the built-in Remote Desktop Connection app. The computer to connect to will be
localhost:3390
. Make sure Xorg is selected as the Session type.With this method (as with WSLg) there is no need to configure any firewall rules, since you really are using WSL's built-in localhost forwarding, which routes
localhost
traffic to WSL when there isn't a listening socket on that port in Windows.I personally find this far easier than the other answers here regarding third-party X servers. It is probably not, however, the most memory efficient since it requires running a desktop environment.
xrdp Summary and Scoring:
Ease of installation: Excellent as long as the desktop manager does not require Systemd (e.g. Gnome). Getting Systemd to run in WSL is currently a major challenge. Third-party helpers are available, but the system and usage of WSL change drastically under Systemd.
Ease of use: Pretty good - Isn't automatically configured to startup when needed, so it's not quite as seamless as WSLg. Some people have reported that it is not as performant as VcXsrv, but I've also experienced excellent performance.
Flexibility: Least flexible for windowing options. You must run a window manager, at least, and configure it for xrdp. It cannot run single-applications on the Windows desktop. Both WSLg and third-party X Servers can run either full-screen or windowed.
This method does run under Windows 10 and should run under WSL1 as well, although I can't remember if I've actually tested xrdp with WSL1.
Memory Consumption: As I expected, this technique has by far the highest memory consumption. Starting the Xfce4 desktop under xrdp consumed an additional 687MB under Vmmem.
Performance: My personal use of xrdp has been limited to simple UI apps, and performance has been pretty responsive. However, deeper inspection shows that this is certainly the worst option for performance. H.264 video playback using VLC stutters heavily, and the glmark2 score of 167 is about half that of VcXsrv.
Third-party X Server in Windows such as VcXsrv
Finally, the "normal" recommended method (as mostly mentioned in the other answers here) for Windows 10 and/or WSL1 is to install a third-party X server in Windows and configure Ubuntu in WSL (version 1 or 2) to use it.
I will add that the older methods of setting the
DISPLAY
variable for WSl2 are probably a bit out of date. I recommend using:This utilizes mDNS (the
.local
domain) which has been available in Windows 10 and WSL for a few years now. Since yourhostname
in WSL Ubuntu is the same as your Windows "computer name", this automatically connects to the correct IP address of the Windows host.For WSL2, a firewall rule will need to be in place for this option, since you are connecting "across network" (albeit a virtual network). In my experience, Windows will detect the attempt to connect the first time and request user action to automatically create a firewall rule. However, if this message is missed or dismissed, the rule will have to be configured manually.
For WSL1, no firewall rule is necessary, and the "normal"
DISPLAY=:0
should work, since it shares the same network interface as Windows (where the X Server is running).Getting a third-party X Server set up is certainly not the "easiest", so I recommend reading through the other answers here (and elsewhere), if you run into trouble with that technique.
One additional note regarding the firewall rules -- The WSL2 network under Windows is classified as a "Public" network interface, and there doesn't seem to be an easy way to change this in recent Windows releases. It used to be possible, but now that interface is hidden and can't be changed. This means that you have to set up your firewall rules to allow VcXsrv (or any third-party X server) on public networks. This can be a problem if you connect to other untrusted, Public networks.
Remember to either:
Third-party X Server - Summary and Scoring:
Ease of Installation: Most trouble-prone of the three options, IMHO. Your results may vary, but as you can see from the number of answers (and questions posted across the Stack sites), people do tend to run into various issues with this technique. Cross-network communication (from the Windows host to the WSL2 virtual network) complicates matters.
Ease of Use: Moderate to Easy once installed and configured properly. While WSLg will start "on demand" when the first GUI app is executed in WSL, you do need to start the third-party X server yourself when you need it. Or you could leave it up and running at all times, but this will mean longer-term memory use.
Flexibility: High - Can run either windowed or full-screen. No Wayland option currently.
Runs on Windows 10/11 and WSL1/WSL2.
Memory Consumption: The best case of these three options. Consumed only 48MB total -- 10MB increase in Vmmem and another 38.6MB for VcXsrv itself.
Performance: While I've tended to prefer xrdp, my benchmarking today will have me taking a closer look at VcXsrv in the future (and perhaps other X servers, such as MobaXterm). VcXsrv does some OpenGL acceleration, apparently, and its glmark2 score of 322 was just about double that of xrdp's. VLC playback of H.264 was smooth, even at 3440x1440 (sorry, no 4k with which to test).
Footnote: Measuring memory
To determine the rough memory usage of each technique, I looked at the Vmmem process memory consumption in Windows. This is the virtual machine process that handles WSL2. I rebooted Windows between most of these tests as well, but did a
wsl --shutdown
between tests of the same technique.Note that it is possible to enable PulseAudio with each of these options, but only WSLg includes it pre-configured out-of-the-box. I did not enable PulseAudio support on either xrdp or VcXsrv options, so whatever memory is needed there (if you need audio support) is not taken into account.
Footnote: WSLg memory consumption
There are apparently two "bumps" in memory consumption with WSLg. The first occurs when you start WSL2 with WSLg simply "enabled" (the default). I didn't notice this increase at first, because I've never disabled WSLg. It is entirely possible to turn the feature off entirely by editing the
.wslconfig
file (see this doc) and settingguiApplications=false
in the[wsl2]
section.After disabling that feature and restarting my Ubuntu WSL2 instance, my base memory usage dropped 108MB. Turning it back on and restarting showed an increase in "steady state" WSL2 memory consumption. So there's a small penalty to having this enabled all the time.
Then when starting up the initial x client (
xterm
in this case), there's another 105MB bump in Vmmem.Footnote: Optimizations
In general, I ran each of these methods using the out-of-the-box, default configuration. I did enable OpenGL acceleration in VcXsrv, and my Windows nVidia drivers are the latest and confirmed to be used for OpenGL Mesa in Ubuntu.
There may be additional optimizations possible for each technique that would improve performance.
Since you want it easy... There is an app in the Microsoft Store called x410. It's basically a Cygwin X11 server without the use of Cygwin itself. After installment - that is zero config - you can run WSL X11 Apps! (or even whole desktops). You might want to insert the following lines into your .bashrc (from your WSL user account) so you can run the apps from your bash terminal.
I bought x410 on salve for about 5euro's.. So if it's too much, perhaps wait for an sale!
I chose Panther's answer not only because it's the only, but also because it's the correct answer; there is no hassle-free (straightforward) way to get gui apps running.
Also, I used this tutorial, with a few changes:
xfce
, because I don't know why I would need a desktop.Multiple Windows
inXLaunch
(No DE, hence no need for one giant window)What gui apps did I install? Only Synaptic and CMake, since I really can't think of anything else I would need on wsl.
I don't do VM/Dual Boot, for the very same reason Panther pointed out; I need a convenient (to me) dev environment, not a full flex OS.