microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.34k stars 814 forks source link

Installing a GUI with WSL and Ubuntu windows 10 #8130

Open jbensabat opened 2 years ago

jbensabat commented 2 years ago

Hello I have installed WSL (hopefully version 2) and ubuntu 20.04. I am trying to install a GUI following many procedures found in the web (SDDM lightDM etc). all of them fail with an error "could not start display server on vt 1" running lightdm I get the error "failed to get system bus could not connect : no such file or directory failed to get D-Bus connection Is there a systematic guide for the installation of a GUI ? thanks jac

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

elsaco commented 2 years ago

@jbensabat you also need WSLg at https://github.com/microsoft/wslg which is available for Windows 11 only. For Windows 10 you'll have to install a 3rd-party X server,

jbensabat commented 2 years ago

hi thanks I still cant update to windows 11 I tried installing VcXsrv but nothing really happens could you recommend a X server that works ? best jac

eseglem commented 2 years ago

@jbensabat I was just playin around with this a few days ago and was struggling. MobaXterm is the only X server that I got to work. It automatically detected the WSL distro so I opened it and ran a GUI command and it opened right up on my screen.

elsaco commented 2 years ago

@jbensabat VcXsrv from https://sourceforge.net/projects/vcxsrv/ does a very good job on Windows 10. Just make sure to open your host firewall for the X server to accept requests from Linux clients. I've set my system to use xauth but there's an alternative setup. The instructions are at https://sourceforge.net/p/vcxsrv/wiki/VcXsrv%20%26%20Win10/

This is a sample xterm from a WSL Ubuntu client running cmd.exe:

xterm_running_cmd

And this is how the firewall inbound rules look on my system:

VcXsrv_windows_firewall

Any red vcxsrv inbound rules are good starting point to troubleshoot connectivity.

jbensabat commented 2 years ago

Hi thanks a lot for the help will try now best jac

Auntrach commented 2 years ago

@elsaco I have Windows 10 and am wondering how to install a 3rd-party X server. According to Microsoft Docs, you can install Linux GUIs for the WSL Ubuntu 20.04 on Windows 10 if you are a Windows Insider. I am wondering if you sign up for Windows Insider, will it give you previous Insider builds?

elsaco commented 2 years ago

@Auntrach on Windows 10 I'm using vcxsrv. I use the same X server on Windows 11. There is wslg but it uses RDP. I prefer X.

After installing vcxsrv port 6000 must be opened for WSL clients to access the X server. In my experience I found it reliable to use the vEthernet (WSL) virtual adapter instead of the host IP. Adjust accordingly if the WSL adapter was renamed from default. I was getting disconnects when using the host network interface for X access.

Here's sample firewall rule used, after removing the rules added by vcxsrv installer:

New-NetFirewallRule -Program "C:\Program Files\VcXsrv\vcxsrv.exe" -DisplayName "X11" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 6000 -RemoteAddress 172.18.144.0/20

And for authentication I'm using xauth. To setup the token it's easier to start from a Linux host, since vcxsrv doesn't include the mcookie app. In a Linux shell generate a hash to be added to .Xauthority file. Sample output:

[tux@RIPPER ~]$ mcookie
71dc675d524cfb6e1cc488ef656d0bb8

Set your $DISPLAY variable to match the vEthenet (WSL) IP, which is also the gateway address. In my case it was export DISPLAY="172.18.144.1:0", then add it to xauth store:

xauth add $DISPLAY MIT-MAGIC-COOKIE-1 71dc675d524cfb6e1cc488ef656d0bb8

Verify with xauth list and xauth info. After, copy the .Xauthority to your $HOME directory on Windows 10 and tell vcxsrv to use this file for authentication:

%ProgramFiles%\VcXsrv\vcxsrv.exe -multiwindow -clipboard -auth C:\Users\tux\.Xauthority

Now Linux clients will be able to display output on the X server. Sample xterm window: arch_info

There is good info at https://www.guide2wsl.com/x11/ also.

Auntrach commented 2 years ago

@jbensabat I finally found that, according to Microsoft Docs, the Linux GUIs can only be installed on Windows 10 Pro, or Enterprise, or basically any of them except Windows 10 Home. I don't know which version you have, but I have Windows 10 Home, so I am out of luck. If you have another version, you may still be able to do it. I switched to the Microsoft Store version of Ubuntu on Windows, and I am going to have to content myself with a command line for the time being.

Biswa96 commented 2 years ago

It is somehow possible to use wslg thingy with Windows 10 but it's dangerous. You've warned. Here is my repository https://github.com/Biswa96/initrdg

elsaco commented 2 years ago

@Auntrach if you're using the X server there should be no issues running Linux GUI apps on Windows 10 Home edition. The info on Microsoft site is for wslg which sadly won't run on Windows 10. IMO, the X server is faster compared to wslg, with the later using RDP to display Linux GUIs.

Auntrach commented 2 years ago

@Biswa96 I looked at what you wrote and decided not to try it. I think it is over my head. You said you could mess up your operating system, so I didn't want to go into it.

@elsaco I am going to try the X server, though. That looks like a better, i.e. safer, solution.

Auntrach commented 2 years ago

@elsaco So if you install Ubuntu for Windows, or Ubuntu 20.04 from the Microsoft Store, and couple it with an X server, that will allow you to run Linux GUI apps on Windows 10 Home?

cuonghuunguyen commented 2 years ago

https://opticos.github.io/gwsl/ Setup on Windows 10