THE FOUNDER’S GUIDE:

How to Install Programs With a Graphical User Interface in WSL2

The condensed tutorial with instructions and screenshots

David Littlefield
4 min readDec 11, 2020
Image by Sean Foley

The expanded version of this article explains each step with enough detail to learn what’s happening.

Download VcXsrv:

  1. Visit the official website
  2. Click “Download”

Install VcXsrv:

  1. Open “vcxsrv-64.1.20.8.1.installer.exe”
  2. Click “Next”
  3. Click “Install”
  4. Click “Close”

Allow Access to VcXsrv:

  1. Check “Private Networks”
  2. Click “Allow Access”

Open PowerShell:

  1. Press “⊞ Windows”
  2. Enter “PowerShell” into the search bar
  3. Right-click “Windows PowerShell”
  4. Click “Run as Administrator”

Open the Bash Configuration File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
notepad //wsl$/Ubuntu-18.04/home/$USER/.bashrc

Set the Display Variable:

  1. Find the arrow from below these instructions
  2. Copy the code to the left of the arrow
  3. Paste the code into Notepad
  4. Click the “File” menu
  5. Click “Save”
export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2> /dev/null):0

Disable Indirect Rendering:

  1. Find the arrow from below these instructions
  2. Copy the code to the left of the arrow
  3. Paste the code into Notepad
  4. Click the “File” menu
  5. Click “Save”
  6. Click the “File” menu
  7. Click “Exit”
export LIBGL_ALWAYS_INDIRECT=0

Exit WSL:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
exit

Name the Task:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
$name = "Graphical User Interface (WSL2)"

Specify the Action:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
$action = new-scheduledtaskaction -execute "c:\program files\vcxsrv\vcxsrv.exe" -argument "-ac -nowgl -multiwindow -dpms"

Specify the Trigger:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
$trigger = new-jobtrigger -atstartup -randomdelay(new-timespan -seconds 30)

Run as the User:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
$principal = new-scheduledtaskprincipal -userid $env:username -runlevel highest

Remove the Time Restriction:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
$settings = new-scheduledtasksettingsset -executiontimelimit 0

Register the Task:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
  4. Restart the computer
register-scheduledtask -taskname $name -action $action -trigger $trigger -principal $principal -settings $settings

Open PowerShell:

  1. Press “⊞ Windows”
  2. Enter “PowerShell” into the search bar
  3. Right-click “Windows PowerShell”
  4. Click “Run as Administrator”

Open WSL:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
wsl

Install Firefox:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
sudo apt install firefox

Open Firefox:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
firefox https://whatsmyos.com/

Next Steps:

This article is part of a mini-series that helps readers set up everything they need to start using WSL2 for artificial intelligence, machine learning, deep learning, and or data science. It includes articles that contain instructions with copy and paste code and screenshots that help readers get the outcome as soon as possible. It also includes articles that contain instructions with explanations and screenshots that help readers process what’s happening.

01. Install Windows Subsystem for Linux 2 (WSL2)
02. Install the NVIDIA CUDA Driver and Toolkit in WSL2
03. Install Software From Source Code in WSL2
04. Install the Jupyter Notebook Home and Public Server in WSL2
05. Install Virtual Environments in Jupyter Notebook in WSL2
06. Install Programs With a Graphical User Interface in WSL2
07. Install Ubuntu Desktop With a Graphical User Interface in WSL2

Hopefully, this article helped everyone get the prize. If you want to help out then hold the “👋” and click “Follow” to get more content. Thanks for reading!

--

--

David Littlefield

From: Non-Technical | To: Technical Founder | Writes: To Make It Easier For Everyone | Topics: #Startups #How-To #Coding #AI #Machine Learning #Deep Learning