Wsl Versions

To set version 2 (Hyper-V):

PS> wsl --list
Ubuntu-20.04 (Default)
PS> wsl --set-default-version 2
(may tell you to update kernel version)
PS> wsl --set-version Ubuntu-20.04 2
(may take some time to convert)

X11 server

I use Vcxsrv (presumably short for Visual C++ X Server)

You need to run the following script inside the Linux VM

export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0

Then with Vcxsrv you need to disable access control.

Then you need to create a hole in the Windows firewall.

  1. Open Control Panel -> System and Security -> Windows Defender Firewall
  2. Select Advanced Settings
  3. Select Inbound Rules in the left pane
  4. Find the VcXsrv windows xserver entries (hint: sort by name)
  5. Enable access for public networks

If you are on a home network, this is fine. If you are somewhere where being this permissive security-wise is risky, take care.