How to Run a Linux Desktop Using the Windows Subsystem for Linux

Key Takeaways

  • Run a Linux desktop on Windows using Windows Subsystem for Linux by installing X server & LXDE for GUI.
  • Ensure Windows 11 is compatible & follow the setup guide to successfully install Windows Subsystem for Linux.
  • Install Linux desktop app on WSL if a full desktop is unnecessary. Access media files in Linux environment.



Running Linux alongside Windows has proven increasingly useful over the years. However, dual booting can be difficult to manage, and setting up a virtual machine has some stability issues. One solution is to use the Windows Subsystem for Linux. Here’s how to run a Linux desktop on Windows using the Windows Subsystem for Linux.


What Is the Windows Subsystem for Linux?

Windows Subsystem for Linux (WSL) is an optional feature for Windows 10 and 11 that supports the installation of the Linux operating systems available in the Windows Store. The Linux on Windows experience got even better with the release of WSL 2 on Windows 11, which brought a full Linux kernel, managed virtual machines, and full system call compatibility.


WSL lets you open a Linux terminal in Windows and install and run Linux software without needing virtualization apps or dual booting. However, the problem with Windows Subsystem for Linux is that it is purely a command-line experience. There is no desktop. This probably won’t be a problem for power users, but as Linux has a wide selection of desktop environments, it does seem a bit of an oversight.

Fortunately, you can install a Linux desktop in Windows with WSL.

Make Sure Windows 11 Is Compatible

Before proceeding, here’s the important bit: you need to run a 64-bit version of Windows.

You can check Settings > System > About, where you’ll find the System type. To proceed, this should read “64-bit operating system”. If not, and you’re running 64-bit hardware, you’ll need to upgrade your Windows installation from 32-bit to 64-bit.


Check if your Windows version is 64-bit

To run WSL 2, you need Windows 11 or Windows 10 version 1903 with build 18362 or higher. If you’re just looking to run WSL, you need to be running Windows 10 build 14393 or later. You can find this in the same About screen, listed under Windows specifications. Look for the OS build—if it is higher than 14393, you can use the Windows Subsystem for Linux. If not, simply run a Windows Update.

Once your Windows installation is compatible, follow our guide to installing the Windows Subsystem for Linux. With that set up, it’s time to add a desktop.

Install a WSL Desktop

If you have set up the Windows Subsystem for Linux already, click Start and enter bash. Click the first option (the bash run command) to start using Linux. We use Ubuntu as the preferred Linux operating system.


Start by running an update and upgrading Ubuntu:

sudo apt update

sudo apt upgrade

While this upgrade is running, head to Sourceforge to download and install the VcXsrv Windows X Server utility. Other X Servers are also available for Windows, including Xming and MobaXterm, but we’ll use VcXsrv for this guide.

An X server lets you access a Linux application or desktop environment’s graphic user interface (GUI). Linux systems rely on X for displaying the desktop, but it can also be used across a network. Ensure your X window server is installed before proceeding. The next step is to install your Linux desktop environment (LDE).

Many Linux desktop environments are available for WSL. We’re going to keep things simple and install a lightweight environment called LXDE. To install, input:

sudo apt install lxde 

After installing LXDE, input this command:


export DISPLAY=:0

export LIBGL_ALWAYS_INDIRECT=1

This instructs Linux to display the desktop through the X server. So you will see the desktop environment when you run the X server program you previously downloaded.

VcXsrv features the XLaunch tool. Click this to view the X Display Settings window. Select One large window or One large window without a title bar. Also, look for the Display number and set it to 0.

Configure an X server in Windows

Click Next and select Start no client to ensure the XLaunch starts only the server, allowing you to start the Linux desktop later. Click Next and Finish. You might also want to click Save Configuration.

Configure X server with WSL on Windows


Ready to launch your Linux desktop? Enter the command to start your preferred LDE. For LXDE, for example, use:

startlxde 

The Linux desktop environment should then appear!

LXDE running on Windows with WSL

You can now run any of the preinstalled Linux software and even install new apps and utilities. Other WSL-compatible desktop environments include KDE. You can even install GNOME on Windows for a full Ubuntu desktop experience.

Don’t Want a WSL Desktop Environment? Just Install a Linux App

In addition to installing a Linux desktop, you can simply install a Linux desktop app from Windows 10. This is useful if you consider installing a full desktop for one to be overkill.

For example, to install the Rhythmbox media player and run it in Linux on Windows, use:


sudo apt install rhythmbox 

Ensure that you have set the export command:

export DISPLAY=:0 

Then simply run the app from the bash prompt:

rhythmbox 

The media player will launch, ready for you to browse for a library.

Linux app running in Windows with WSL

In this case, you would need to add some media files to the Linux environment on your computer. You can do this by installing a browser and downloading files or simply by hooking up a USB drive with media files on it.

After connecting the USB drive, remember to mount it (this example uses D: as the drive letter):

sudo mount -t drvfs D: /mnt/d 

When you’re done, you’ll need to unmount the drive before removal. This ensures the integrity of the data on the drive.


sudo umount /mnt/d 

While browsing your Windows folders from within the Linux apps is possible, no actual files can be opened. This is a shortcoming of the Windows Subsystem for Linux, albeit one that protects both the Windows and Linux environments from damage.

While this can be overcome by letting you access your Windows files in the Linux environment, keep in mind that the Linux and Windows file systems aren’t fully compatible. So, avoiding accessing either of their files on the other OS is generally better.

Leave a Reply

Your email address will not be published. Required fields are marked *