Featured image of post Install GUI in WSL2 using VcXsrv

Install GUI in WSL2 using VcXsrv

Introduction how to install GUI desktop in WSL2 with VcSxrv in winsows 10.

Install Step

Install WSL

First check if you Windows 10 Version supports WSL 2 or not checkout the Link and Install.

Download VcSxrv

Download X server connected tool, I use VcXsrv.

Update Ubuntu 20.04 to the latest version

1
2
$ sudo apt-get update
$ sudo apt-get upgrade

x-server VcXsrv configuration

Open the Ubuntu 20.04 LTS terminal and type below to install XFCE4 Desktop:

1
2
$ sudo apt-get install x11-apps
$ sudo apt-get install xfce4

When you install xfce4, you maybe need to select the Default Display Manager link this:

If you don’t how to select, you can reference What is LightDM and GDM.

After the installation finished, open .bashrc add some configuration.

1
2
$ cd ~
$ vi .bashrc

Go to the last line and write this

1
2
3
# For WSL2
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.0
export LIBGL_ALWAYS_INDIRECT=1

and Exit your WSL and run it again.

Now after we got everything we need, let’s start the session

1
$ startxfce4

and go back you windows to open VcXsrv main program(XLaunch) you can use you GUI in WSL

Congratulations!! Now you can use your WSL using Graphical User Interface.

Reference

Licensed under CC BY-NC-SA 4.0
Last updated on Aug 12, 2021 18:37 CST
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy