Introduction
"I'm using WSL2 on Windows to work with Linux commands, but can't I open apps in a GUI?"
"I heard it's possible to display the WSL2 desktop via RDP, but the setup seems complicated..."
WSL2 (Windows Subsystem for Linux) is usually command-line focused, but by combining it with tools like xrdp, you can operate a RDP (Windows Remote Desktop) Linux GUI environment. In this article, I will explain the process of installing
xrdp + desktop environment on WSL2 on Windows and performing GUI operations via an RDP client. It takes a little effort, but let's experience the comfort of being able to run GUI apps and use a file browser!
Learning consultation via LINE:
xCamp official website:
1. What are the benefits of using a GUI in WSL2?
-
Use Windows and Linux on one machine
Easier file editing with a GUI file browser
Display Linux apps in a GUI while running Visual Studio Code on the Windows side
-
Easily share screens without SSH
Log in with an RDP client → Familiar Windows-like operation feel
-
Perfect for learning and verification
Run Docker and containers on WSL2 while trying out GUI tools
Caution: Honestly, there are still experimental elements → Depends on Windows updates and WSL2 version
2. Prerequisites: WSL2 is enabled & Ubuntu etc. are already installed
-
Windows 10 (2004) or later or 11:
Control Panel → Enable WSL in “Turn Windows features on or off”
Complete updates so that “WSL2” can be used
Microsoft Store and install Ubuntu (or another distro)
Set to WSL2 mode: wsl --set-default-version 2 wsl -l -v # Check if the distro is Version 2
Check if basic commands(apt-get, etc.) work in WSL2
3. Install a desktop environment (Xfce, etc.)
-
Launch Ubuntu:
Launch from Windows Terminal or the Ubuntu app
Installing Xfce4 (lightweight desktop environment): sudo apt-get update sudo apt-get install xfce4
Some additional packages(fonts and tools): sudo apt-get install xfce4-goodies
-
Test:
Normally an X server is required, but since we will display it later via RDP rather than WSL2 alone, it is not yet in a state where the GUI can be launched here
4. Install & configure xrdp
xrdp installation: sudo apt-get install xrdp sudo systemctl enable xrdp sudo systemctl start xrdp
-
Specify desktop session(Xfce4 example): echo xfce4-session > ~/.xsession
Launch Xfce4 when logging in via xrdp
-
Open port 3389 (WSL2 side is treated as relatively local, but depends on network settings):
Adjust with Windows Firewall, etc.
Port visibility for WSL2 changes depending on bridge/virtual NIC settings
5. Connect with Windows RDP client
-
Check IP address:
Check the WSL2 IP with ip addr show (e.g., 172.19.xxx.xxx)
WSL2 networking is complex → It might be tied to the loopback
-
Launch 'Remote Desktop Connection (mstsc)' on Windows:
Connection target: WSL2-IP:3389
-
Username & Password:
Ubuntu username/pass
-
Check if the GUI desktop appears
Success if the Xfce4 screen appears
Note: The IP may change → You need to re-check after a reboot
6. Common troubleshooting
-
Screen goes black
~/.xsession is not configured or desktop environment is missing → echo xfce4-session > ~/.xsession
-
Port 3389 is not open
Windows firewall or network connectivity issue
-
IP address unknown
Check the WSL2 IP with ip addr show → However, if Windows cannot access that IP, separate configuration is required
-
RDP connection works but mounting is unstable
WSL2 is a virtual environment → There are some limitations with Windows file system integration
7. Learn infrastructure + Linux operations at xCamp
xCamp is a school where you can learn the basics of AWS and Linux for free. You can also ask questions about advanced operations like WSL2 + xrdp.
Mentor Support: “The IP changes in WSL2...”, “Why is the RDP screen black?” → Resolve minor troubles immediately
Career Change Support: “I used Linux GUI via RDP even in a Windows environment” → Unique operational track record
Free slots available on a first-come, first-served basis → Try it out risk-free
Learning consultation via LINE:
xCamp Official Website:
8. Summary
By setting up WSL2 + xrdp, you can operate Windows Remote Desktop (RDP) to control Linux GUI.
Install a desktop environment like Xfce4
Introduce xrdp and write xfce4-session to ~/.xsession
Access WSL2-IP:3389 from Windows using mstsc
Interact with Ubuntu via GUI
xCamp helps you learn the basics of infrastructure and Linux thoroughly, making it easier to apply these operational tricks to your own environment. Please try experiencing the fun of running GUI apps on WSL2!
Official X account: https://x.com/_Xcamp_
Our company engineer (Yuta-san): https://x.com/310engineer
Our company engineer (Reo-kun): https://x.com/Reo_engineer_