Guide to install WSL 2 and run GUI apps

Adithya S.T.
Republic of Coders — India
5 min readFeb 3, 2021

--

WSL 2 is a new version of the Windows Subsystem of Linux architecture in Windows 10 increases file system performance and adds full system call capability.WSL 2 is a full Linux kernel capable of running on Windows systems. In this guide I’ve compiled the steps to install WSL 2 and also the steps to install GUI applications and a GUI desktop environment

  1. Enable WSL and Virtual Machine Platform

Open Powershell or Command Prompt and enter the following commands:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestartdism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Alternative method:

Search for ‘features’ in the start menu search bar

Click on Turn Windows features on or off

Click on Virtual Machine Platform and Windows Subsystem for Linux to enable them

2. Restart your system

3. Install Ubuntu from Microsoft Store

4. Run the Ubuntu app and give username and password

5. Update Kernel:

Install this package to update to the latest kernel:https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

6.Change the default version of WSL to 2:

wsl --set-default-version 2

7. Verify:

Run the following command:

wsl -l -v

If the version is 1 then execute the following command:

wsl --set-version Ubuntu 2

The conversion can take 1 hour or even more

Rerun the command to verify the version

8. Update Ubuntu to support GUI:

Update Ubuntu:

sudo apt update && sudo apt -y upgrade

Install remote desktop utilities:

sudo apt install build-essentialsudo apt install net-toolssudo apt install xrdp -y && sudo systemctl enable xrdpsudo apt install build-essentialsudo apt install net-toolssudo apt install xrdp -y && sudo systemctl enable xrdp

9.Install xfce4 desktop environment:

sudo apt install -y taskselsudo tasksel install xubuntu-desktopsudo apt install gtk2-engines

10. Setup Display Variables for GWSL:

Execute the following command:

nano ~/.bashrc

Go to the end of the file and copy and paste these lines:

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0export LIBGL_ALWAYS_INDIRECT=1sudo /etc/init.d/dbus start &> /dev/null

11. Setup PulseAudio:

Download PulseAudio for Windows:http://bosmans.ch/pulseaudio/pulseaudio-1.1.zip

Extract the files in a folder called ‘pulse’ in C drive

In the pulse directory go to etc/pulse folder and make the following configurations:

  1. Edit default.pa:

Open default.pa file using notepad

In line 42

change load-module module-waveout sink_name=output source_name=input

to:

load-module module-waveout sink_name=output source_name=input record=0

At the top of the file copy and paste these lines:

load-module module-native-protocol-tcp port=4713 auth-ip-acl=172.16.0.0/12
load-module module-esound-protocol-tcp port=4714 auth-ip-acl=172.16.0.0/12
load-module module-waveout

2. Edit daemon.conf:

In line 39:

Change ; exit-idle-time = 20

to:

; exit-idle-time = -1

3. Edit the bash file in Ubuntu:

Open the Ubuntu terminal and run the following command:

nano ~/.bashrc

Go to the end of the file and paste the following line:

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

12. Start PulseAudio:

Go to the pulse/bin and run pulseaudio.exe

13. Install GWSL

Install GWSL from Microsoft Store

Run GWSl

14.Open an App:

Open the Ubuntu terminal and run Firefox using the command:

firefox &

(‘&’ after the application name makes the application to run in the background so you can continue using the terminal)

Or:

In GWSL click on Linux Apps

Scroll down and click on Firefox

15.Run full linux desktop:

Run the following command to run the xfce4 desktop environment:

xfce4-session

Note: You must be running GWSL and PulseAudio in the background everytime for GUI and audio to work

Now you would be able to run GUI apps and access Linux using a GUI Desktop environment, all this without the help of a VM!

Cheers✌

--

--