WSL ubuntu security Gnome desktop VcXsrv access


  • Windows 10 system, or newer

  • Windows has installed WSL2 ubuntu system

  • Windows has installed “Terminal” in “Microsoft Store”, which is the terminal software

  • Windows has installed the “Chocolatey” tool, see reference link 1

  • WSL ubuntu has installed the “git” tool

WSL ubuntu installs Gnome desktop

  • Enter the following command in the terminal connected to ubuntu of WSL to install the desktop

sudo apt-get install ubuntu-gnome-desktop

The package is not small, it may take some time to wait. You can try the fast-apt tool.

  • Configure the current user’s .bashrc file

vi ~/.bashrc

Add the following at the end and save

export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0

take effect

source ~/.bashrc

windows install VcXsrv software

  • Open the windows terminal as an administrator and execute the following statement

choco install vcxsrv

If the choco command cannot be recognized, see connection 1 in the reference section

  • configuration

  • Open the “XLanunch” program after installation

  • Display settings interface

You can keep the default value, the following configuration is recommended, as shown in the figure below

  • Select “One large window”, you can manually adjust the window size later

  • Display number: fill in 0 (default -1 is also acceptable)

  • Client startup interface

Keep the default “Start no client” option

  • Extra settings

The third option “Disable access control” needs to be selected, otherwise the following error will be reported when starting the graphics program in the WSL ubuntu terminal: Authorization required, but no authorization protocol specified

“Next step” and wait for the desktop client to connect.

Check whether WSL ubuntu and VcXsrv are accessible

  • WSL ubuntu terminal, run the following command


VcXsrv is displayed as follows

At this time, VcXsrv can already display the graphical interface program in WSL ubuntu.

  • ubuntu boot desktop

Execute the following command in the wsl ubuntu terminal to start the desktop

sudo gnome-session

Note: If ubuntu does not install “systemctl”, it will fail to start by default. See the next section for the installation method of systemctl.

WSL ubuntu install systemctl program

  • wsl ubuntu terminal executes the following command

git clone
cd ubuntu-wsl2-systemd-script/
# Enter your password and wait until the script has finished
  • Restart wsl ubuntu, test systemctl command

  • closure

Execute the following command in a non-wsl ubuntu terminal

wsl --shutdown
  • Start WSL-ubuntu

  • Execute the systemctl command in the WSL ubuntu command line. If some list units are displayed without error messages, the installation is successful.


After systemctl is successfully installed, first open VcXsrv, and then use the “ubuntu start desktop” command in the previous section to let VcXsrv display the ubuntu gnome desktop.


  • Windows installation package management tool Chocolatey_qq_16740151’s Blog – CSDN Blog

  • Windows 10/11 wsl installation ubuntu_wsl installs multiple ubuntu_qq_16740151’s blog – CSDN Blog

  • DamionGans/ubuntu-wsl2-systemd-script: [Does not work anymore!] Script to enable systemd support on current Ubuntu WSL2 images (

  • WSL ubuntu xfce4 desktop remote connection_wsl2 remote desktop_qq_16740151’s blog-CSDN blog

  • WSL2 configuration in Windows to run GNOME desktop version Ubuntu_Hack Electronics Blog-CSDN Blog

  • WSL2 + VcXsrv Open the graphics window for visualization_wsl2 visualization_ToreannyTang’s Blog-CSDN Blog