Watch the video:
0:00 - Explanation 0:44 - Install WSL 1:17 - Set WSL version 2 2:04 - Install 3:30 - Fix DNS 4:30 - Installing Desktop environment 5:20 - Set up RDP 5:56 - Connect using Windows Remote Desktop 6:28 - Using other desktop environments
Why and why not
A GUI is the simplest way of interacting with a computer. If using a GUI is necessary for people to test out Linux, then it’s essential. You don’t need one of these to use GUI programs under WSL. Some programs just launch, and you can see them; others require a few steps. This is for a full-blown desktop environment, much like you’d get if you installed Ubuntu or any other distro under a virtual machine/hypervisor like Hyper-V or VMWare.
You can do this, but you should become more reliant on the command line rather than a GUI - especially if you’re looking to work with Linux servers in the future. The command line will become a second home.
Set up Windows and a Linux distro
I’ll be using Ubuntu as it’s the most popular and most widely supported OS for the most part. There are more tutorials and guides for getting out of sticky situations here than in any other distro.
To start, you need to ensure Windows can run WSL.
Start, then search for and open “Windows Features”.
You will need to make sure that both
Windows Subsystem for Linux and
Virtual Machine Platform are ticked. Hit OK and restart your computer if necessary.
Now, we need to set the WSL environment to version 2.
- Open Powershell as administrator or Terminal on Windows 11. Then enter
wsl --set-default-version 2. If prompted, download the WSL2 kernel and install it, then rerun the command.
Now we can install a Linux distro. I will use Ubuntu.
- Open the Windows Store and search for “Ubuntu”, or your distro of choice. This guide is specifically for Ubuntu or another Debian-based distro, so make sure you’re modifying things where necessary if you’re not.
While installing, you will need to set up an account and the rest. Click through doing whatever is nessecary.
Now, update Ubuntu.
sudo apt-get update -y && sudo apt-get upgrade -yto update the OS.
If you run into an issue where nothing happens or time out, run
sudo nano /etc/resolv.conf and change the
nameserver x.x.x.x to
nameserver 126.96.36.199 for Google DNS, or
nameserver 188.8.131.52 for Cloudflare’s DNS.
Verify that everything is up-to-date with
lsb_release -a, or install Neofetch (
sudo apt install neofetch) and run
Set up the Desktop Environment
Now, for the exciting bit. We’ll set up a desktop environment and use a remote access tool to interact with it. Remote Desktop is included with Windows. If you can install WSL you already meet the minimum version requirements (I think Windows Pro or higher is needed).
We’ll use XFCE4, as it’s the simplest.
sudo apt install -y xrdp xfce4 xfce4-goodies
Then, run the following:
sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak
sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/max_bpp=32/#max_bpp=32\nmax_bpp=128/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/xserverbpp=24/#xserverbpp=24\nxserverbpp=128/g' /etc/xrdp/xrdp.ini
echo xfce4-session > ~/.xsession
To finish setting up the RDP access:
sudo nano /etc/xrdp/startwm.sh, then comment out the following lines by placing a
test -x /etc/x11...and the next line;
echo /bin/sh /etc/x11...
- Now, add the following on a new line at the very end:
- Save and close with
- Start RDP with:
sudo /etc/init.d/xrdp start.
Now, open Remote Desktop on your Windows host machine, and connect to
Article bonus info
While you may be tempted, like I was, to install the official Ubuntu desktop environment, Gnome… Just don’t. Save yourself hours of time.
While it’s simple enough to set up, getting it to work is a much longer process. Gnome doesn’t work well with WSL, or at least the Ubuntu flavor.
If you want to attempt, here’s as far as I know. If you get it working, please share it with me so I can cover it!
Install the required dependencies:
sudo apt-get install xorg xterm gdm3 menu gksu synaptic --no-install-recommends
Hypothetically you would be able to run either of the following:
sudo apt install ubuntu-gnome-desktopor
sudo apt install ubuntu-desktop-minimal
Then configure the desktop environment
sudo dpkg-reconfigure gdm3
- (Then select gdm3)
- Start the service with
sudo service gdm3 start
And that’s it. Enjoy your working desktop environment, and make the best of it. You will likely get a better experience installing a full-blown VM with Linux. However, this is an excellent way of keeping it tightly integrated with Windows.