Skip to main content

How to install Linux desktop on WSL2 on Windows 11

Categories   Linux Virtual Machine and Container
Tags   Windows Subsystem for Linux KDE Plasma GNOME
Table of Contents


Running a Linux desktop environment and playing audio in Windows WSL.

WSL supports running graphics programs through WSLg. For example, if you install the firefox package in WSL, type firefox command, the program will open in Windows, and you can enjoy GPU hardware acceleration.

Furthermore, you can also use WSL to run GNOME, XFCE, KDE, LXQT, Cinnamon and other desktop environments to experience the feeling of using a Linux computer.

For example, the picture below shows KDE Plasma desktop is running on WSL Ubuntu. You can seamlessly switch between Windows and Ubuntu, and the performance is better than that of a virtual machine.

Video demo

Please note that there are lots of differences between the desktop functions in WSL and the actual Linux machine, and various weird bugs may occur.

If you want to experience the complete Ubuntu desktop, I still recommend that you install Ubuntu on a physical machine, such as dual booting Windows 11 and Ubuntu

1. Environment

  • Windows 11 22H2
  • WSL
  • WSL Ubuntu 22.04

By default, WSL allocates half of your computer’s RAM to Linux. If you want to run a graphics environment, it may be resource intensive. It is recommended to leave at least 4GB of RAM for Linux. You can adjust wslconfig to allow WSL to allocate more hardware resources.

2. Description

Please first look at the WSLg architecture diagram provided by Microsoft.

Why not just use WSLg to display the Linux desktop? Well… WSLg uses the Wayland display protocol and already has its own window manager. It can only launch “single window” programs such as Firefox mentioned at the beginning of the article, but cannot launch new desktop environments.

When you start Firefox, the window will be “snatched” by WSLg. But I hope that after opening a Linux desktop environment window, all Linux programs will stay in that window.

So it is better to run a separate X server. All X programs run in the same window.

There are three choices for X server:

  1. Run independent X server programs such as VcXsrv and X410 outside WSL
  2. Running Xephyr in WSL
  3. Running XWayland within WSL

I choose to run Xephyr or XWayland within WSL. This is equivalent to running a nested X server in WSL’s Walyand.

For the audio, since it is very complex to run standalone Pulse Aduio sever on Windows, we will use the built-in audio server of WSLg to play WSL audio.

Since WSLg uses Wayland, below we will use environment variables to force all Linux programs to use X instead of Wayland display to prevent them from running in WSLg windows.

3. Install desktop environment packages

Log in to WSL Ubuntu and use APT to install the package.

Choose one of the four, you can install them all if you want. Don’t rush to start it after installing the package.


The default desktop of Kubuntu. It is as beautiful as GNOME.

Package name: kubuntu-desktop or plasma-desktop

Start command: dbus-run --exit-with-session startplasma-x11


The Xubuntu desktop is very lightweight and the default state is a bit ugly.

Package name: xubuntu-desktop or xfce4 xfce4-goodies

Start command: dbus-run --exit-with-session startxfce4


Lubuntu’s desktop is as lightweight as XFCE.

Package name: lubuntu-desktop or lxqt

Start command: dbus-run --exit-with-session startlxqt


The default desktop of Ubuntu system. Note that I am not sure that GNOME can be launched because there are some problems related to systemd

Currently WSL2 1.2.5 requires additional script for GNOME installation, please refer to WSL 2 GNOME Desktop - Github gist

4. Start the desktop environment

  1. Install WSL Ubuntu, log in to WSL
  1. Save environment variables to ~/.profile to force programs to use X rendering entirely. If you don’t do this, Linux programs opened in the X server window may run outside the window of X server.
echo "export XDG_SESSION_TYPE=x11" >> ~/.profile
echo "export GDK_PLATFORM=x11" >> ~/.profile
echo "export GDK_BACKEND=x11" >> ~/.profile
echo "export QT_QPA_PLATFORM=xcb" >> ~/.profile
echo "export WAYLAND_DISPLAY=" >> ~/.profile

source ~/.profile
  1. Start the X server (choose one of the two) and specify the resolution as 1600x900. A new window will pop up after startup.
# Xephyr command, the window can be resized
Xephyr -br -ac -noreset -resizeable -screen 1600x900 :1 &

# XWayland command, the window cannot be resized (the option geometry arguments can only be used in XWalyand 23.0 or newer, on Ubuntu 22.04 you have to manually compile the new version of XWayland)
Xwayland -ac -decorate -geometry 1600x900 -host-grab :1 &
  1. Next, start a desktop environment, such as KDE, in the terminal. I added & at the end of the command to make it run in the background so that we can continue to use the terminal.
export DISPLAY=:1
dbus-launch --exit-with-session startplasma-x11 &
  1. After a few seconds, the KDE desktop will be shown in the X window.

  2. To close the desktop environment, log out of WSL and shut it down

wsl --shutdown

5. Configure Ubuntu language and input method

The language can be set from the KDE system settings.

Or it could be generated using the following command, for example, Chinese:

sudo apt install locales
sudo locale-gen zh_TW.UTF-8
sudo update-locale LANG=zh_TW.UTF-8

For the Chinese input method, since we cannot use Windows IME in Linux, we have to install Fcitx5 + Chewing on the Linux side. If Fcitx5 does not pop up after opening the desktop environment, please click the “Fcitx5” icon in the application list to start it manually.

Press CTRL+SHIFT to grab the keyboard combination in the X server window.

If you want to synchronize the clipboard between Linux and Windows, you can install KDE Connect on both systems. After pairing, the clipboard will be automatically synchronized.

6. Some minor issues

VLC is laggy when playing videos, so use MPV instead.

When playing videos on MPV, you can add the --vo=x11 parameter to force it to run under X11.

mpv video.mp4 --vo=x11

There is no sound in the Snap version of Firefox. It is recommended to remove it and install Firefox ESR provided by Mozilla ppa:

sudo snap remove firefox
sudo add-apt-repository ppa:mozillateam/ppa
sudo apt update
sudo apt install firefox-esr

Some Flatpak programs cannot be opened, and there is currently no solution.



ReDroid. Playing Android games in containers on Linux PC, with GPU Acclelration
Categories   Linux Virtual Machine and Container
Tags   Android Docker Linux
[Guide] Playing Android games on Linux PC with Android-x86 VM + QtScrcpy
Categories   Linux Virtual Machine and Container
Tags   Android-X86 QEMU
10+ Windows galgames that you can play on Linux (And native Linux galgames!)
Categories   Linux Gaming on Linux
Tags   Wine

Leave a comment

Choose the comment system you like. Giscus for codes, Disqus for anonymous comments.

Please login to your Github account to leave a comment. You can post codes here for discussion. For images, please upload to Imgur and copy links. Your comments would be visible to everyone on Github Discussions.

This comment system is provided by Disqus, you may see forcing Disqus ADs on this page. Sometimes your comment may need to be reviewed, resulting in delayed display. Thank you for your understanding.