Setting up a Linux Desktop Environment in Windows 10 WSL

In this guide, I’ll show you how to install and use a XFCE desktop environment in the Windows Subsystem for Linux.

Getting Windows Ready

In order to get a graphical install of Linux working in the Windows Subsystem for Linux (WSL), you will need version 2. WSL2 is only available in Windows 10, Version 2004, Build 19041 or higher. To find out which version of Windows your device is running, press the Windows logo key + R, type winver in the Open box, and then select OK. If you do not meet the requirements, please update your machine before proceeding.

Installing WSL2

Open PowerShell as Administrator and run

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Now, restart your machine. Once again open PowerShell as Administrator and run the following command

wsl --set-default-version 2

You might see this message after running that command:

WSL 2 requires an update to its kernel component.

If you do, visit and install the latest WSL2 Linux kernel. Once you have the kernel installed, run the above command again, and it should complete successfully without showing the message.

Installing Ubuntu 20.04

Open the Microsoft Store and download Ubuntu 20.04 LTS. Once it is downloaded, launch it like you would a normal application. You will see something that looks like the following picture: Create a username and password.

Getting a Desktop Environment Working

You will need to transfer a file from your Windows file system to your Linux file system. The Windows C:\ drive is mounted by default at /mnt/c/. Go to that directory with the following command,

cd /mnt/c

Download the script from my GitHub. Copy it to your Linux home directory with

cp <path to> ~/

Run this script.

cd ~
sudo bash

You will be prompted to choose a display manager, choose gdm3. This script will take a while to run. When the script finishes, close your WSL window. Then, relaunch it.

Starting the Desktop Environment

Now that the script has finished, start the service with

session start

Open the built-in Windows 10 remote desktop program. Enter localhost:3389 in the Computer box, then hit Connect. Click yes if you are asked if you want to connect. Log in with your Linux username and password.

Tweaking the XFCE Desktop

The desktop environment (XFCE in this case) attempts to put the display to sleep after 10 min. This causes the environment to become unresponsive. To fix this, head into the lock screen settings in XFCE. You can find this by clicking the magnifying glass icon in your dock and searching for “Light Locker”. Change your settings to reflect this picture, then apply (“Lock on suspend” will remain on, just make sure to turn off “Enable light-locker” and set “Blank screen after” and “Switch off display after” to “Never”).

Congratulations! You should have a working XFCE desktop environment.

Graduate Physics Student & Researcher

My research interests include Cosmology, High Energy Astrophysics, Gravitational Wave Physics, Computational Science, and HPC in Physics.