VeeamON 2021: Free Online Conference - Register Now VeeamON 2021: Free Online Conference - Register Now

How to Install Linux GUI Apps in Windows 10 with WSL

As more apps are developed in Linux than ever before, Microsoft recognized that it needed to provide developers with an easy way to build, test, and run Linux apps without leaving the Windows desktop. The Windows Subsystem for Linux (WSL) was originally designed to provide an integrated Linux terminal environment in Windows without needing to set up and manage a virtual machine (VM). But what if you want to run a Linux GUI editor, or other GUI app, using WSL?

Microsoft announced on April 21st that WSL in Windows 10 Insider Preview Build 21364 now supports Linux GUI apps. So, using build 21364 and higher, developers can run their preferred GUI editors and tools for testing and building Linux apps without having to jump through hoops like installing an X Server. In this article, I’ll show you how to update WSL to support GUI apps, how to install a GUI app in Ubuntu, and finally look at how GUI Linux apps are integrated with the Windows user interface.

Windows 10 21H2 and Linux GUI app support

Windows 10 21H2 isn’t coming until the second half of 2021 but Microsoft is busy releasing previews to Insiders. Until recently, WSL only officially supported Linux terminal applications. But Microsoft recently came good on a promise it made last year to bring GUI app support to the Windows Subsystem for Linux (WSL). If you don’t know, WSL 2 is a feature in Windows 10 that lets developers add a Linux kernel to Windows and then load terminal support for several Linux distributions, including Ubuntu and SUSE.

For more information on Microsoft’s announcement, check out Microsoft Brings Linux GUI Apps to Windows 10 on Petri.

What can I do with WSL GUI app support?

The primary use case for Linux GUI app support is to run IDEs that are only supported on Linux. While many developers use Visual Studio Code on Windows to connect to their Linux instances in WSL, some developers prefer to use Linux tools like gedit, JetBrains, and gvim.

There are other applications too that only run in Linux. WSL now lets developers run those apps without setting up a Linux VM. The new GUI app support in WSL, sometimes referred to as WSLg, also lets developers test cross-platform GUI apps. There’s even support for audio and microphone.

For resource-intensive graphics applications, WSLg supports 3D acceleration via OpenGL. GPU hardware acceleration can benefit developers running complex apps that take advantage of WSL’s virtual GPU. If you want to experiment with 3d accelerated graphics in WSL, Microsoft says for the time being, you’ll need to manually download a WDDMv3.0 driver for AMD, Intel, and NVIDIA GPUs respectively. These drivers will eventually be deployed automatically using Windows Update.

How does WSL GUI app support work?

When you run a Linux GUI app, Windows automatically starts a companion Linux distribution that includes XWayland, a pulse audio server, and everything needed for Linux GUI apps to run on Windows. Linux GUI apps are integrated with the Windows UI and when you terminate an app, the Linux companion distro session also ends to reduce system resource usage.

How to Install Linux GUI Apps in Windows 10 21H2 with WSL (Image Credit: Microsoft)

WSLg supports Wayland and X11 GUI applications. Microsoft developed WSLg as an open-source application, but it is designed to work without needing any changes. WSLg is isolated from the user’s Linux distribution so that WSLg can be serviced independently. The WSLg companion distro uses CBL-Mariner, a lightweight and customizable Linux distribution maintained by Microsoft’s Linux System Group. CBL-Mariner was originally designed for headless, containerized workloads running in Azure or Microsoft’s edge services.

How to update WSL to support GUI apps

If you have WSL already installed in Windows and are upgrading to Insider Preview Build 21364, then you’ll need to update your existing WSL installation to support WSLg.

Update an existing WSL installation

There are two simple steps to update WSL. First, shutdown any running distros and then update WSL using the wsl.exe command-line tool.

  • Open an elevated command prompt. In the search box in the bottom left of the taskbar, type cmd.
  • In the search results, make sure that Command Line is highlighted and in the panel on the right, click Run as administrator.
  • Give consent or type an administrator username and password as prompted.
  • In the command line window, run the following type commands.

How to Install Linux GUI Apps in Windows 10 21H2 with WSL (Image Credit: Russell Smith)

WSLg only supports WSL 2, so you’ll need to make sure any existing and future Linux distributions are configured to run in WSL 2. You can set existing distributions to use WSL 2 using the –set-version switch and by replacing distroname with the name of a Linux distribution installed on your PC. Use wsl –list -v to show the Linux distributions you have installed on your PC.


Then restart WSL to complete the process:

Install WSL for the first time with GUI app support

If you want to install WSL for the first time in Windows 10 Build 21364 or higher, then you just need to install WSL using the command line. WSLg support comes built-in. The command below installs WSL and then adds the Ubuntu distribution. You’ll be prompted to reboot your PC.

Installing Linux GUI apps in Ubuntu

Now launch your Linux distribution from the Windows Start menu. In this example, I’m using Ubuntu, so I’ll find the Ubuntu icon in the apps list on the Start menu. Clicking the Ubuntu icon launches an Ubuntu terminal window. Now install Linux GUI apps in the same way you would on any other Ubuntu distro.

For example, because Ubuntu is based on Debian, use the apt command to install apps. You’ll need to sudo the command to run it with elevated privileges in Linux. The first step is to update all my existing packages in Ubuntu:


Here I use apt to install Nautilus, a GUI file manager for Linux:

How to Install Linux GUI Apps in Windows 10 21H2 with WSL (Image Credit: Russell Smith)

Another example is to install the preview version of Microsoft Edge for Linux. Here I need to download the package from Microsoft’s website and then run it using apt.

Starting Linux GUI apps and integration with the Windows UI

Once your chosen apps have been installed, you’ll find them in the apps list on the Windows Start menu. Launch your Linux GUI apps like you’d run any Windows app.

How to Install Linux GUI Apps in Windows 10 21H2 with WSL (Image Credit: Russell Smith)

Alternatively, you can launch GUI apps from your Linux terminal window. For example, to launch Nautilus from the terminal, I’d just type nautilus and press ENTER. Or microsoft-edge and press ENTER to run Microsoft Edge.

How to Install Linux GUI Apps in Windows 10 21H2 with WSL (Image Credit: Russell Smith)

Edge is even identified as distinct from the version installed in Windows by the penguin in the bottom-right of the application icon.

How to Install Linux GUI Apps in Windows 10 21H2 with WSL (Image Credit: Russell Smith)

Linux GUI apps in Windows 10

WSLg is still a work in progress but it seems far along at this stage. Microsoft will be tweaking it in upcoming Insider builds before Windows 10 21H2 launches later in 2021. In my short time with it, WSLg seemed to work as expected. I didn’t install the virtual GPU graphics drivers as recommended by Microsoft. But even without them, everything seemed to work just fine.

If you can’t wait to get official support for Linux GUI apps in WSL, then you can switch to the Insider channel. Although these updates for WSL are currently only available to Insiders on the Dev Channel, which is considered the most unstable. So, you might want to wait until either the official 21H2 release or at least until WSLg makes it to the Beta or Release Preview Channels.

Related Topics:

  • Windows 10
  • BECOME A PETRI MEMBER:

    Don't have a login but want to join the conversation? Sign up for a Petri Account

    Register
    Comments (0)

    Leave a Reply

    IT consultant, Contributing Editor @PetriFeed, and trainer @Pluralsight. All about Microsoft, Office 365, Azure, and Windows Server.

    Free Online Conference - May 25th and 26th

    VeeamON 2021: Free Online Conference

    Join us to gain your professional edge with technical and visionary learning from the brightest minds in IT at the definitive conference for Modern Data Protection.

    Register Now

    Sponsored By