I am running XFCE on a WSL2 based Ubuntu installation on my Windows machine. See WSL section on how to set this up.
I wanted to install GParted running sudo apt install gparted.
GParted is installed in /usr/sbin
However, when I selected GParted in Applications -> System, nothing happened.
When trying to run it directly from /usr/sbin, nothing happened but I saw the following error message:
Error getting authority: Error initializing authority: Could not connect: No such file or directory
Then I tried to run sudo gparted. Nothing happened, but I got the following error message:
Authorization required, but no authorization protocol specified
(gpartedbin:695): Gtk-WARNING **: 19:27:48.494: cannot open display: :15.0
Then I saw this answer on the internet: https://askubuntu.com/a/981508/71690
I ran the command xhost +SI:localuser:root
Then I ran sudo gparted again ét voila! Gparted was running on my XFCE GUI running on an Ubuntu based WSL2 installation!