Windows Subsystem for Linux (WSL) is a powerful tool that allows you to run Linux applications directly on your Windows machine. However, running GUI-based applications can be a bit tricky. This article will guide you through the process of running GUI apps under WSL using two methods: WSLg and X server.
Yes, it is possible to run GUI apps under WSL using two methods: WSLg and X server. WSLg provides an integrated solution for running GUI apps directly on the Windows desktop, while using an X server involves installing an X server software on your Windows system and configuring WSL to use it.
WSLg is an integrated solution for running GUI apps under WSL. It is available for both Windows 10 and Windows 11. WSLg provides a Wayland/Weston/Xwayland distribution that allows you to run GUI apps directly on the Windows desktop.
To use WSLg, you need to ensure that your Windows 10 build number ends in
.2311 or higher. You can check your build number by typing
winver into the Windows search bar. If you need to update, you can install the necessary optional Preview update (KB5020030) from the “Optional Updates” section in Windows Update.
Installation and Update
Once your system is up-to-date, you can install or update WSL using the following commands in your command prompt:
This command installs WSL if it’s not already installed. If WSL is already installed, you can update it using:
You can confirm the version of your WSL using:
This should return
1.0.0 or later.
Using X Server
Another option to run GUI apps in WSL is to set up an X server. This involves installing an X server software on your Windows system and configuring WSL to use it. One popular X server for Windows is Xming.
Installing X Server
You can download Xming from here. Once downloaded, run the installer and follow the on-screen instructions.
Configuring WSL to Use X Server
After installing Xming, you need to configure WSL to use it. This involves setting the
DISPLAY environment variable in your WSL shell to point to Xming. You can do this by adding the following line to your shell’s startup file (e.g.,
~/.bashrc for bash):
This tells WSL to send all X11 output to the Xming server running on your Windows host.
When running GUI apps under WSL, you may encounter errors related to the display server. For example, if you’re running an app on Wayland with root permission, you might see an error message. In such cases, you can try restarting your session without Wayland or running the app without root permission.
Running GUI apps under WSL can be achieved using either WSLg for an integrated solution or an X server like Xming for a more traditional approach. Both methods have their pros and cons, so choose the one that best fits your needs. With the right setup, you can enjoy the power of Linux applications directly on your Windows desktop.
Yes, you can run GUI apps under WSL on Windows 10 using either WSLg or an X server like Xming.
You can check the build number of your Windows 10 system by typing
winver into the Windows search bar.
To install WSL, use the command
wsl --install in your command prompt. To update WSL, use the command
You can confirm the version of your WSL by using the command
wsl --version in your command prompt. It should return
1.0.0 or later.
Yes, there are other X servers available for Windows, such as VcXsrv and Cygwin/X.
You can set the
DISPLAY environment variable in WSL by adding the line
export DISPLAY=:0 to your shell’s startup file, such as
~/.bashrc for bash.
If you encounter errors related to the display server, you can try restarting your session without Wayland or running the app without root permission.
The choice between WSLg and an X server depends on your needs. WSLg provides an integrated solution, while an X server offers a more traditional approach. Consider the pros and cons of each method before deciding.