ホーム 暮らし Connecting to WSL2 from Windows Remote Desktop!? Tips for enjoying GUI apps

Connecting to WSL2 from Windows Remote Desktop!? Tips for enjoying GUI apps

東條 淳平 東條 淳平 • 更新: • 公開: • 読了約 12 分
目次

Introduction

n29bbfd43cacf

"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

  1. 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

  2. Microsoft Store and install Ubuntu (or another distro)

  3. Set to WSL2 mode: wsl --set-default-version 2 wsl -l -v # Check if the distro is Version 2

  4. Check if basic commands(apt-get, etc.) work in WSL2


3. Install a desktop environment (Xfce, etc.)

  1. Launch Ubuntu:

    • Launch from Windows Terminal or the Ubuntu app

  2. Installing Xfce4 (lightweight desktop environment): sudo apt-get update sudo apt-get install xfce4

  3. Some additional packages(fonts and tools): sudo apt-get install xfce4-goodies

  4. 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

  1. xrdp installation: sudo apt-get install xrdp sudo systemctl enable xrdp sudo systemctl start xrdp

  2. Specify desktop session(Xfce4 example): echo xfce4-session > ~/.xsession

    • Launch Xfce4 when logging in via xrdp

  3. 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

  1. 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

  2. Launch 'Remote Desktop Connection (mstsc)' on Windows:

    • Connection target: WSL2-IP:3389

  3. Username & Password:

    • Ubuntu username/pass

  4. 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

  1. Screen goes black

    • ~/.xsession is not configured or desktop environment is missing → echo xfce4-session > ~/.xsession

  2. Port 3389 is not open

    • Windows firewall or network connectivity issue

  3. IP address unknown

    • Check the WSL2 IP with ip addr show → However, if Windows cannot access that IP, separate configuration is required

  4. 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.

  1. Install a desktop environment like Xfce4

  2. Introduce xrdp and write xfce4-session to ~/.xsession

  3. Access WSL2-IP:3389 from Windows using mstsc

  4. 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_

同じカテゴリの記事

東條 淳平

スポーツと芸能が交差する話題を担当。大会公式記録と所属先の発表を突き合わせ、数字は必ず出典付きで扱います。

おすすめの関連記事