Note
If you want a more complete experience and already tried the Xvnc tutorial, maybe you should try the WSLg (Xwayland) instead.
Warning
This is a work in progress tutorial. Things done here may break existing functionality, so be careful!
In this tutorial, we will install and use a full GNOME Desktop environment in WSL2, without any external software. The only requirement is a working WSLg installation. At the moment, the instructions are only for Ubuntu (20.04, 22.04 and 24.04) distros and GNOME, but you can request me to test other distros and desktop environments.
- No fullscreen support
- No complete desktop support (with Display Manager)
- No support to clipboard (copy & paste) from/to Windows
-
Open a Ubuntu (20.04, 22.04 or 24.04) terminal. First of all, we need to make sure everything is up to date.
sudo apt update sudo apt upgrade -
WSL doesn't install the app store by default, so we can install it manually (or you can skip this step if you don't need it).
sudo snap install snap-store -
Now we can install the required packages. This may take a long time, so be patient.
sudo apt install ubuntu-desktop acpi-support-sudo apt install ubuntu-desktop
Important
Note the minus sign (-) after the package acpi-support. This is necessary because it will be installed by default and installing it will render your distro almost unusable (see microsoft/WSL#10059), so we will tell apt to not install it.
-
Now we have everything installed, we must configure some things before using the GNOME Shell. First, we need to deactivate the GDM service, because unfortunately it doesn't work with WSLg yet (at least I didn't figure it out how to make it work).
sudo systemctl mask gdm.service -
Now we need to fix the directory
/tmp/.X11-unix/, because it's mounted as read-only by default. We will create a newsystemdunit.sudo systemctl edit --full --force wslg-fix.service -
Paste the code below in the editor.
[Service] Type=oneshot ExecStart=-/usr/bin/umount /tmp/.X11-unix ExecStart=/usr/bin/rm -rf /tmp/.X11-unix ExecStart=/usr/bin/mkdir /tmp/.X11-unix ExecStart=/usr/bin/chmod 1777 /tmp/.X11-unix ExecStart=/usr/bin/ln -s /mnt/wslg/.X11-unix/X0 /tmp/.X11-unix/X0 [Install] WantedBy=multi-user.target[Service] Type=oneshot ExecStart=-/usr/bin/umount /tmp/.X11-unix ExecStart=/usr/bin/rm -rf /tmp/.X11-unix ExecStart=/usr/bin/mkdir /tmp/.X11-unix ExecStart=/usr/bin/chmod 1777 /tmp/.X11-unix ExecStart=/usr/bin/ln -s /mnt/wslg/.X11-unix/X0 /tmp/.X11-unix/X0 ExecStart=/usr/bin/chmod 0777 /mnt/wslg/runtime-dir ExecStart=/usr/bin/chmod 0666 /mnt/wslg/runtime-dir/wayland-0.lock [Install] WantedBy=multi-user.target -
Save the file and close the editor. Now we have to enable this service.
sudo systemctl enable wslg-fix.service -
The last step is to configure the GNOME Shell to start in nested mode.
sudo mkdir /etc/systemd/user/gnome-shell-wayland.service.d/ sudo nano /etc/systemd/user/gnome-shell-wayland.service.d/override.confsudo mkdir /etc/systemd/user/org.gnome.Shell@wayland.service.d/ sudo nano /etc/systemd/user/org.gnome.Shell@wayland.service.d/override.conf -
Paste the code below in the editor.
[Service] ExecStart= ExecStart=/usr/bin/gnome-shell --nested -
Save the file and close the editor. Then close the distro terminal window.
-
Finally we will shutdown WSL.
wsl.exe --shutdownThe configuration is complete.
-
Now open again your distro terminal, then paste the command below.
DESKTOP_SESSION=ubuntu \ GDMSESSION=ubuntu \ GNOME_SHELL_SESSION_MODE=ubuntu \ GTK_IM_MODULE=ibus \ GTK_MODULES=gail:atk-bridge \ IM_CONFIG_CHECK_ENV=1 \ IM_CONFIG_PHASE=1 \ QT_ACCESSIBILITY=1 \ QT_IM_MODULE=ibus \ XDG_CURRENT_DESKTOP=ubuntu:GNOME \ XDG_DATA_DIRS=/usr/share/ubuntu:$XDG_DATA_DIRS \ XDG_SESSION_TYPE=wayland \ XMODIFIERS=@im=ibus \ MUTTER_DEBUG_DUMMY_MODE_SPECS=1366x768 \ gnome-session -
A GNOME Shell window will appear.



I could get this incantation to display the ubuntu-26.04 desktop, but found that it had some serious drawbacks - there isn't a valid gnome-session associated with the gnome-shell, or a logind context, so anything that requires credentials (eg. such as App Center) is just totally broken.
Full Desktop for Ubuntu-26.04.1 LTS / WSLg
The Ubuntu 26.04 desktop (GNOME 50) is Wayland only and doesn't support X11/Xorg, which is why the instructions for Ubuntu 24.04 don't work. However with a small modification, they can be made to work:
Installing the required packages
Configuring the environment
Starting the GNOME Shell
Enabling graphics acceleration
Adding
GALIUM_DRIVER=d3d12to the gnome-session startup command may improve the rendering performance and enable some desktop animation effects. However for me it meant that App Center would no longer launch. You can fix this as follows:Remote Desktop Connections
The gnome-shell override also works if you want instead to display the desktop using GNOME remote desktop functionality. After performing steps 1-6 above, add the following:
localhost:3390. You should get the Ubuntu greeter screen, followed by the desktop once you have entered your RDP password.For reference, my WSL environment is:
Full disclosure - there are a couple of small wrinkles with this approach because of the way WSLg operates:
I suggest you start with the lightweight desktop install first, as the full install includes features (such as network selection), that cannot realistically function inside WSL and may make the desktop unstable.
The mutter devkit windows appear to have their own sizing rules. They can be resized, but this is not persistent across restarts. They can be maximized to fill the physical windows display, but there doesn't appear to be a way to make them properly full screen.
If you use the remote desktop approach, a regular windows RDP window will momentarily appear (correctly sized according to the RD connection rules) but filled completely black, but it will then disappear before the greeter login window is displayed.
Again for the remote desktop approach, once the login has completed and main desktop window appears, the greeter window will go black but will not automatically close. You can safely close it manually at this point.
If you use Visual Studio Code, it will create and launch in its own WSLg window, rather than staying within the Ubuntu desktop window bounds.