참고 사이트

https://docs.microsoft.com/ko-kr/windows/wsl/tutorials/gui-apps

 

WSL을 사용하여 Linux GUI 앱 실행

WSL에서 Linux GUI 앱 실행을 지원하는 방법을 알아봅니다.

docs.microsoft.com

https://psychoria.tistory.com/739

 

Windows 10 WSL 2에서 리눅스 GUI 프로그램 실행하기

Windows 10 2004 업데이트에 WSL 2(Windows Subsystem for Linux 2)이 포함되었습니다. WSL 2를 설치하는 방법은 아래 링크에서 확인 가능합니다. 2020/07/07 - [Windows/Tip&Tech] - Windows 10 2004에서 WSL 2..

psychoria.tistory.com

 

 

설정 과정중에 hashrc 설정을 해도 GUI 적용안될수 있음.

하라는데로 해서 gedit 호출했는데 UI가 안뜸.

같은 문제가있어 확인

 

https://stackoverflow.com/questions/61860208/wsl-2-run-graphical-linux-desktop-applications-from-windows-10-bash-shell-erro

 

WSL 2: Run Graphical Linux Desktop Applications from Windows 10 Bash Shell "Error E233: cannot open display"

How to run graphical Linux desktop applications from Windows 10’s Bash Shell? First, I installed Windows Subsystem for Linux (WSL) following steps as shown in here as follows: (1) Installed Windo...

stackoverflow.com

 

 

해당 답변대로 적용하니 동작함.

 

WSL2에 대한 DISPLAY 변수 설정

nameserverMicrosoft 설명서 에 따라 /etc/resolv.conf파일 에서 DISPLAY 변수를 확인하도록 설정할 수 있습니다 . ( @fqquiner  @VPraharsha는 이미 이것을 언급했습니다)

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

그러나 WiFi 연결 및 여러 가상 네트워크가 있는 노트북을 사용하기 때문에 이 솔루션을 사용하는 데 문제가 있었습니다. 기존 솔루션 대신 route.exe기본 게이트웨이에서 사용하는 인터페이스를 확인하여 Windows IP 주소를 확인합니다.

 

난이걸로해결이 된듯 하다 

$ sudo vim ~/.bashrc

$ i    (수정)

esc    (뷰모드로)

$ :w   (저장)

$ :q   (나가기)

export DISPLAY=$(route.exe print | grep 0.0.0.0 | head -1 | awk '{print $4}'):0.0

 

DISPLAY 변수 설정.profile

sudo vim ~/.profile

# set DISPLAY to use X terminal in WSL
# in WSL2 the localhost and network interfaces are not the same than windows
if grep -q WSL2 /proc/version; then
    # execute route.exe in the windows to determine its IP address
    DISPLAY=$(route.exe print | grep 0.0.0.0 | head -1 | awk '{print $4}'):0.0

else
    # In WSL1 the DISPLAY can be the localhost address
    if grep -q icrosoft /proc/version; then
        DISPLAY=127.0.0.1:0.0
    fi

fi

윈도우 터미널 에서 wsl 종료

wsl --shutdown

 

아래의 방화벽설정도 꼭필요하다.

 

27

Had the same problem so I tried these other suggestions but what ended up working was allowing vcxsrv through the public firewall. I know you're not using vcxsrv but perhaps it's the same problem for you too.

Install VcXsrv then enable public firewall like these pictures. Open Windows Defender Firewall with Advanced Security using wf.msc at command prompt. Then allow connections like in these pictures.

VcXsrv를 설치한 다음 이 그림과 같이 공용 방화벽을 활성화합니다. 명령 프롬프트에서 wf.msc를 사용하여 고급 보안이 포함된 Windows Defender 방화벽을 엽니다. 그런 다음 이 그림과 같은 연결을 허용합니다.

[

Then run VcXsrv from this guide for Windows 10 WSL2

Run VcXsrv by adding -ac addition parameter or type this at command prompt "C:\Program Files\VcXsrv\vcxsrv.exe" :0 -multiwindow -clipboard -wgl -ac

Then type this into your WSL2 terminal

 

그런 다음 Windows 10 WSL2용 이 가이드에서 VcXsrv를 실행합니다.

-ac 추가 매개변수를 추가하여 VcXsrv를 실행하거나 명령 프롬프트 "C:\Program Files\VcXsrv\vcxsrv.exe"에 입력하십시오. :0 -multiwindow -clipboard -wgl -ac  (<-난 이부분은 적용안함 밑의 터미널 입력만 하니 적용됨)

그런 다음 이것을 WSL2 터미널에 입력하십시오.

export DISPLAY_NUMBER="0.0"
export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):$DISPLAY_NUMBER
export LIBGL_ALWAYS_INDIRECT=1
# OPTIONAL Set the keyboard layout to US
setxkbmap -layout us
setsid emacs
exit
 

+ Recent posts