Linux with a desktop environment running under Windows 11

Published on by

WindowsxUbuntu

Background & Functionality

It is very easy to run a complete Linux environment including its graphical user interface on a Windows computer. Windows Remote Desktop is used as a client to access the graphical user interface of Linux based on the installed desktop environment (e.g. “Xfce”1). It feels as if Linux and its desktop environment are installed directly on the computer. The following features are supported:

  • Copy & paste files between the Windows desktop and the Linux desktop environment
  • Multi-monitor operation
  • Video-Streaming, e.g. YouTube
  • Preview: Connecting USB devices, e.g. audio/video via “usbipd-win”2

Prerequisites

  • At least Windows 113 is installed
  • WSL24 must be enabled on Windows 11
  • Curl5 must be present on Windows 11 (Installed by default since Windows 10)

Steps

  1. Download the rootfs-image for WSL of a Linux distribution - in our case we are using Ubuntu Mantic6

    - inside Windows Command Prompt -

    • Press the keyboard shortcut Windows-Key + R-Key
    • Type cmd in the small window and confirm with the Return key or click OK
    • Creating a Folder
      mkdir "%userprofile%\mylinux"
      
    • Download Distribution
      curl https://cloud-images.ubuntu.com/wsl/mantic/current/ubuntu-mantic-wsl-amd64-wsl.rootfs.tar.gz --output "%userprofile%\mylinux\mylinux-rootfs.tar.gz"
      
      
  2. Import the downloaded rootfs-image

    - inside Windows Command Prompt -

    • Start the import process
      wsl --import mylinux "%userprofile%\mylinux\vhdx" "%userprofile%\mylinux\mylinux-rootfs.tar.gz"
      
  3. Check the Import

    - inside Windows Command Prompt -

    • List the installed subsystems
      wsl -l -v
      
    • The import was successful if “mylinux” appears in the list of distributions
      NAME       STATE           VERSION
      mylinux    Stopped         2
      
  4. Launch Linux Distribution

    - inside Windows Command Prompt -

    • Launch the installed subsystem
      wsl -d mylinux
      
    • Note: The Windows Command Prompt switches to the terminal of the Linux distribution for the first time
  5. Check the Distribution inside the Terminal of the Linux Distribution

    - inside Linux Terminal -

    • Show release information
      lsb_release -a
      
    • The resulting output should look like this
      No LSB modules are available.
      Distributor ID: Ubuntu
      Description:    Ubuntu 23.10
      Release:        23.10
      Codename:       mantic
      
    • Assign a password for the user “root”
      passwd root
      
    • Note: The password must be entered twice in a row
    • Important: Within the Xrdp environment, the user “root” is required for security-critical processes such as mounting drives
  6. Install the desktop environment “Xfce” and “Xrdp”7

    - inside Linux Terminal -

    • Install the needed packages
      apt update && apt install -y xfce4 xrdp
      
    • The technical user “Xrdp” must be assigned to the group “ssl-cert”
      adduser xrdp ssl-cert
      
    • Create a new user “tux” for the login via “Xrdp”
      useradd -m -g users tux
      
    • Assign a password for the new user “tux”
      passwd tux
      
    • Note: The password must be entered twice in a row
  7. Prepare the custom X-Session

    - inside Linux Terminal -

    • Switch to the user “tux” previously created
      su - tux
      
    • Edit the x-session configuration
      echo xfce4-session >> ~/.xsession
      
    • Leave the tux user session
      exit
      
  8. Configuring the Linux distribution to use “systemd”

    - inside Linux Terminal -

    • Edit the configuration for WSL
      echo -e "[network]\nhostname=mylinux\n[boot]\nsystemd=true" > /etc/wsl.conf
      
    • Leave the terminal of the Linux distribution afterwards
      exit
      
  9. Shut down WSL and restart the Linux distribution

    - inside Windows Command Prompt -

    • The subsystem must first be terminated to initiate a reboot afterwards
      wsl -t mylinux
      
    • Very important Note: If another subsystem is running, under which another Xrdp server is active on the default port 3389, it is mandatory to reboot Windows at this point!
    • Boot the Linux distribution
      wsl -d mylinux
      
    • Note: The Windows Command Prompt switches back to the terminal of the Linux distribution
  10. Check if Xrdp is started

    - inside Linux Terminal -

    • Check if Xrdp is running correctly
      systemctl status xrdp
      
    • The first two lines of the resulting output should look like this
      ● xrdp.service - xrdp daemon
      Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; preset: enabled)
      Active: active (running) since ...
      .
      .
      .
      
  11. Important: It is required to start a separate Windows Command Prompt

    • The Linux Terminal must remain open
    • Press the keyboard shortcut Windows-Key + R-Key
    • In the small window, type cmd and confirm with the Return key or click OK
  12. Identify IP address used by WSL

    - inside Windows Command Prompt -_

    • Check IP addresses used by WSL
      wsl hostname -I
      
    • Possibly the resulting output are multiple IP addresses, e.g.
      172.25.107.5 172.18.0.1 172.20.0.1
      
  13. Access the remote desktop by using the first IP address displayed

    - inside Windows Command Prompt -

    • Start a new remote desktop session
      mstsc /v:"172.25.107.5"
      
  14. Log in via the Remote Desktop Client

    - inside Windows Remote Desktop -

    • Enter tux as username
    • Log in with the password previously set for the tux user
    • The desktop of Xfce will be displayed

Optional: Complete uninstallation of the Linux distribution

Attention: Removes everything that has been downloaded or created in the previous steps

  • Downloaded root-fs-image “mylinux-rootfs.tar.gz”

  • Created virtual disk “ext.vhdx”

  • Stored data within the Linux distribution

  • The following steps are needed

    - inside Windows Command Prompt -

    • Press the keyboard shortcut Windows-Key + R-Key
    • In the small window, type cmd and confirm with the Return key or click OK
      wsl --unregister mylinux
      
      rmdir /s /q "%userprofile%\mylinux"
      

  1. ↗ https://www.microsoft.com/de-de/software-download/windows11  ↩︎

  2. ↗ https://learn.microsoft.com/en-us/windows/wsl/install  ↩︎

  3. ↗ https://curl.se  ↩︎

  4. ↗ https://releases.ubuntu.com/mantic  ↩︎

  5. ↗ https://xfce.org  ↩︎

  6. ↗ http://www.xrdp.org  ↩︎

  7. ↗ http://www.xrdp.org  ↩︎

See also

  1. → ics2csv4win - Transform iCalendar resources (ics) to character-separated values (csv)

Disclaimer: The information in this article is to be understood as a non-binding reference.
The up-to-dateness, correctness and completeness of the content cannot be guaranteed.