logo

Running Linux CLI and GUI Applications on Windows Using WSL 2

O

Ohidur Rahman Bappy

MAR 22, 2025

Introduction

With Windows Subsystem for Linux 2 (WSL 2), you can run Linux GUI applications directly on Windows 10. This post guides you through setting up and running these applications using a shortcut.

Link to parent tutorial

What is a Linux Desktop Environment?

A Desktop Environment in Linux provides a window manager and other essential components like a Windowing system and a Display server. This setup is crucial when developing software, as it supports tools like IDEs and web browsers.

What is WSL 2?

WSL 2 allows you to run a real Linux kernel inside a lightweight utility VM integrated with Windows. You can install and run your favorite Linux distributions and binaries on Windows.

Running Linux GUI Applications Using WSL 2

To run Linux GUI applications, you'll need a Windowing system and a Display server. Here are two methods:

  1. Install a desktop environment (e.g., Gnome, KDE) and connect via RDP.
  2. Install an X Server like VcXsrv and set it as a Display server for WSL 2.

Creating Shortcuts for Linux GUI Applications

You can create shortcuts to launch Linux GUI apps from the Windows Start menu:

  1. Create a Batch Script

    @echo off
    for /f "tokens=3 delims=: " %%I in ('netsh interface IPv4 show addresses "vEthernet (WSL)" ^| findstr /C:"IP Address"') do set ip==%%I
    set ipAddress=%ip:~1%
    Powershell.exe wsl "DISPLAY='%ipAddress%':0" %1
    

    This script fetches the WSL host IP address, sets it in the DISPLAY variable, and runs the GUI application.

  2. Create a Visual Basic Script

    Create a .vbs script for your application (e.g., firefox.vbs):

    Set oShell = CreateObject ("Wscript.Shell") 
    Dim strArgs
    strArgs = "cmd /c wsl-app-runner.bat firefox"
    oShell.Run strArgs, 0, false
    
  3. Create a Shortcut

    Right-click the .vbs file to create a shortcut, rename it, and optionally change its icon.

  4. Move the Shortcut

    Copy the shortcut to the Start menu directory: C:\Users\YOUR_USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs.

Image for post

Now, you can search and launch the application from the Start menu.

Image for post

Repeat the process for additional applications. Below is an example of running gnome-system-monitor:

Image for post

Conclusion

Integrating Linux GUI applications via WSL 2 into Windows 10 enhances productivity, allowing seamless operation of your favorite Linux tools like Firefox or IntelliJ Idea alongside Windows applications.