PROGRAMMING:

How to Install the Ubuntu Desktop With the Graphical User Interface in WSL2

Nice and easy tutorials with step-by-step instructions

David Littlefield
Geek Culture

--

Summary:

This article installs the Ubuntu Desktop with Graphical User Interface in WSL2. It installs the required Linux programs, Ubuntu Desktop, display server, dotnet runtime, systemd daemon, and sound server. It installs the public key, package resource list, scripts, background service, and firewall rules. It also runs the Ubuntu Desktop and installs the application store.

Table of Contents:

  1. Install the Requirements
  2. Specify the Ubuntu Version
  3. Install the Genie Repository
  4. Install the Ubuntu Desktop
  5. Install the Sound Server
  6. Configure the Ubuntu Desktop

Appendix:

  1. Tutorials: Artificial Intelligence Set Up
  2. Tutorials: Artificial Intelligence Course
  3. Tutorials: Artificial Intelligence Repositories

Install the Requirements:

This section installs the required Linux programs, installs the x11 display server, changes the execution policy, and autorizes vcxsrv in the firewall.

# open the powershell shell
1. press “⊞ windows”
2. enter “powershell” into the search bar
3. right-click "windows powershell"
4. click “run as administrator”
# open windows subsystem for linux
wsl
# update the linux package manager
sudo apt update
# upgrade the linux packages
sudo apt --yes upgrade
# set the windows account username
username=$(wslvar username)
# install the linux programs
sudo apt install --yes axel unzip imagemagick apt-transport-https libpulse0
# download vcxsrv
axel --num-connections 10 --output "/mnt/c/users/${username}/downloads/vcxsrv.exe" https://sourceforge.net/projects/vcxsrv/files/vcxsrv/1.20.6.0/vcxsrv-64.1.20.6.0.installer.exe
# change the execution policy to run scripts in powershell
powershell.exe -command set-executionpolicy unrestricted -force
# install vcxsrv
powershell.exe -c "invoke-item 'c:\users\\${username}\downloads\vcxsrv.exe'"
# create a firewall rule to authorize vcxsrv
powershell.exe -command 'new-netfirewallrule -displayname vcxsrv -direction inbound -program "c:\program files\vcxsrv\vcxsrv.exe" -profile any -action allow'

Specify the Ubuntu Version:

This section downloads the Microsoft public key and package resource list.

# download the microsoft public key
sudo apt-key adv --fetch-keys https://packages.microsoft.com/keys/microsoft.asc
# add microsoft to the source list directory for ubuntu 18.04
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/prod bionic main" > /etc/apt/sources.list.d/microsoft-prod.list'
# add microsoft to the source list directory for ubuntu 20.04
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/20.04/prod focal main" > /etc/apt/sources.list.d/microsoft-prod.list'

Install the Genie Repository:

This section installs dotnet runtime and genie to enable systemd.

# download dotnet runtime
axel --num-connections 10 --output /mnt/c/users/${username}/downloads/dotnet.exe https://download.visualstudio.microsoft.com/download/pr/b2696089-c2ea-4cb4-8d3e-4e5840bdc57b/ffbc7ae206aba305bcbc90b8df5b7421/dotnet-runtime-5.0.8-win-x64.exe
# install dotnet runtime
powershell.exe -command "c:\users\\${username}\downloads\dotnet.exe"
# enter the shell as the root user
sudo --shell
# download the gpg key
axel --output /etc/apt/trusted.gpg.d/wsl-transdebian.gpg https://arkane-systems.github.io/wsl-transdebian/apt/wsl-transdebian.gpg
# grant permissions to the gpg key
chmod a+r /etc/apt/trusted.gpg.d/wsl-transdebian.gpg
# add arkane systems to the source list directory
sudo cat << EOF > /etc/apt/sources.list.d/wsl-transdebian.list
deb https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main
deb-src https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main
EOF
# update the linux package information
sudo apt update
# install genie
sudo apt install --yes systemd-genie
# exit the shell as the root user
exit

Install the Ubuntu Desktop:

This section installs the ubuntu-desktop package, scripts, and icon.

# install ubuntu desktop
sudo apt --yes install ubuntu-desktop
# make the ubuntu subdirectories
mkdir --parents "/mnt/c/users/${username}/.ubuntu/scripts/" "/mnt/c/users/${username}/.ubuntu/images/"
# navigate to the ubuntu directory
cd "/mnt/c/users/${username}/.ubuntu"
# review the bash script that starts the desktop environment
powershell.exe -command "start-process iexplore 'https://gist.github.com/david-littlefield/17a1017a6b1f68e81c40dbceea7696ad/raw'"
# download the bash script
axel --output "/mnt/c/users/${username}/.ubuntu/scripts/start_desktop.sh" https://gist.github.com/david-littlefield/17a1017a6b1f68e81c40dbceea7696ad/raw
# download the ubuntu images
axel --output "/mnt/c/users/${username}/.ubuntu/images/ubuntu_images.zip" https://assets.ubuntu.com/v1/9fbc8a44-circle-of-friends-web.zip
# unzip the ubuntu image
unzip -j "/mnt/c/users/${username}/.ubuntu/images/ubuntu_images.zip" "circle-of-friends-web/PNG/cof_orange_hex.png" -d "/mnt/c/users/${username}/.ubuntu/images/"
# convert the ubuntu image into the ubuntu icon
convert -resize 64x64 "/mnt/c/users/${username}/.ubuntu/images/cof_orange_hex.png" "/mnt/c/users/${username}/.ubuntu/images/ubuntu.ico"
# review the powershell script that reloads vcxsrv
powershell.exe -command "start-process iexplore 'https://gist.githubusercontent.com/david-littlefield/a78d8aad25c58408a4cd48147ac7615f/raw'"
# download the powershell script
axel --output "/mnt/c/users/${username}/.ubuntu/scripts/reload_vcxsrv.ps1" https://gist.githubusercontent.com/david-littlefield/a78d8aad25c58408a4cd48147ac7615f/raw
# review the visual basic script that starts ubuntu
powershell.exe -command "start-process iexplore 'https://gist.githubusercontent.com/david-littlefield/9c84f375c9885fb24668d32619a57bb2/raw'"
# download the visual basic script
axel --output "/mnt/c/users/${username}/.ubuntu/scripts/start_ubuntu.vbs" https://gist.githubusercontent.com/david-littlefield/9c84f375c9885fb24668d32619a57bb2/raw
# review the powershell script that creates the shortcut
powershell.exe -command "start-process iexplore 'https://gist.githubusercontent.com/david-littlefield/cb52bede753c2aa4a3ff05031d803722/raw'"
# download the powershell script
axel --output "/mnt/c/users/${username}/.ubuntu/scripts/create_shortcut.ps1" https://gist.githubusercontent.com/david-littlefield/cb52bede753c2aa4a3ff05031d803722/raw
# create the ubuntu shortcut
powershell.exe -command "c:\users\\${username}\.ubuntu\scripts\create_shortcut.ps1"

Install the Sound Server:

This section downloads, installs, and configures the sound server, creates the background service, and authenticates the sound server in the firewall.

# download pulseaudio to the downloads directory
axel --num-connections 10 --output "/mnt/c/users/${username}/downloads/pulseaudio.zip" https://code.x2go.org/releases/binary-win32/3rd-party/pulse/pulseaudio-5.0-rev18.zip
# unzip pulseaudio in the downloads directory
unzip "/mnt/c/users/${username}/downloads/pulseaudio.zip" -d "/mnt/c/users/${username}/downloads/pulse/"
# move the pulse directory to the root directory of the hard drive
mv "/mnt/c/users/${username}/downloads/pulse/pulse/" /mnt/c/pulse/
# add the environment variables to the bash configuration file
echo -e $(cat << end_of_string
\nexport HOST_IP="\$(ip route |awk '/^default/{print \$3}')"\nexport PULSE_SERVER="tcp:\$HOST_IP"\nexport DISPLAY="\$(cat /etc/resolv.conf | grep nameserver | awk '{ print \$2 }'):0.0"\n
end_of_string
) >> ~/.bashrc
# reload the bash configuration file
source ~/.bashrc
# add the authorized ip address to the pulse configuration file
echo -e 'load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;172.16.0.0/12\nload-module module-esound-protocol-tcp auth-ip-acl=127.0.0.1;172.16.0.0/12\nload-module module-waveout sink_name=output source_name=input record=0\n' >> /mnt/c/pulse/config.pa
# navigate to the default config files directory
cd "/mnt/c/pulse/default config files/"
# disable the automatic shutdown setting
sudo sed "s/; exit-idle-time = 20/; exit-idle-time = -1/" -i "/mnt/c/pulse/default config files/daemon.conf"
# download the nssm service manager
axel --num-connections 10 --output "/mnt/c/users/${username}/downloads/nssm.zip" https://nssm.cc/release/nssm-2.24.zip
# unzip the nssm service manager in the downloads directory
unzip "/mnt/c/users/${username}/downloads/nssm.zip" -d "/mnt/c/users/${username}/downloads/"
# move the nssm service manager to the pulse directory
mv "/mnt/c/users/${username}/downloads/nssm-2.24/win64/nssm.exe" /mnt/c/pulse/
# install the pulseaudio background service
powershell.exe -command "c:\pulse\nssm.exe install pulseaudio c:\pulse\pulseaudio.exe"
# set the pulseaudio executable file path
powershell.exe -command "c:\pulse\nssm.exe set pulseaudio application c:\pulse\pulseaudio.exe"
# set the pulseaudio startup directory
powershell.exe -command "c:\pulse\nssm.exe set pulseaudio appdirectory c:\pulse"
# set the pulseaudio arguments
powershell.exe -command "c:\pulse\nssm.exe set pulseaudio appparameters --file c:\pulse\config.pa"
# set the pulseaudio display name
powershell.exe -command "c:\pulse\nssm.exe set pulseaudio displayname pulseaudio"
# start the pulseaudio background service
powershell.exe -command "net start pulseaudio"
# create a firewall rule to authorize pulseaudio
powershell.exe -command 'new-netfirewallrule -displayname pulseaudio -direction inbound -program c:\pulse\pulseaudio.exe -profile any -action allow'
# exit wsl
exit
# shutdown wsl
wsl.exe --shutdown
# reboot computer
restart-computer

Configure the Ubuntu Desktop:

This section attempts to run the ubuntu-desktop, removes the duplicate firewall rule, runs the ubuntu-desktop, and installs the application store.

# reopen windows subsystem for linux
wsl
# set the windows account username
username=$(wslvar username)
# attempt to run ubuntu desktop (black screen)
powershell.exe -command "invoke-item c:\users\\${username}\.ubuntu\ubuntu.lnk"
# remove duplicate firewall rule for vcxsrv
powershell.exe -command 'remove-netfirewallrule -displayname "vcxsrv windows xserver"'
# run ubuntu desktop using the ubuntu shortcut icon
explorer.exe "c:\users\\${username}\.ubuntu"
# open terminal in ubuntu desktop
1. click the "activities" menu
2. enter "terminal" into the search bar
3. click "terminal"
# install the snap store
sudo snap install snap-store

“Lastly, remember to subscribe and hold down the clap button to get regular updates and help out.”

Appendix:

This blog exists to provide complete solutions, answer your questions, and accelerate your progress related to artificial intelligence. It has everything you need to set up your computer and complete the first half of the fastai course. It will expose you to state-of-the-art repositories in the subfields of artificial intelligence. It will also cover the second half of the fastai course.

Tutorials: Artificial Intelligence Set Up

This section provides everything that’s required to set up your computer.

# linux
01. install and manage multiple python versions
02. install the nvidia cuda driver, toolkit, cudnn, and tensorrt
03. install the jupyter notebook home and public server
04. install virtual environments in jupyter notebook
05. install the python environment for ai and machine learning
06. install the fastai course requirements
# wsl 2
01. install windows subsystem for linux 2
02. install and manage multiple python versions
03. install the nvidia cuda driver, toolkit, cudnn, and tensorrt
04. install the jupyter notebook home and public server
05. install virtual environments in jupyter notebook
06. install the python environment for ai and machine learning
07. install ubuntu desktop with the graphical user interface
08. install the fastai course requirements
# windows 10
01. install and manage multiple python versions
02. install the nvidia cuda driver, toolkit, cudnn, and tensorrt
03. install the jupyter notebook home and public server
04. install virtual environments in jupyter notebook
05. install the programming environment for ai and machine learning
# mac
01. install and manage multiple python versions
02. install the jupyter notebook home and public server
03. install virtual environments in jupyter notebook
04. install the python environment for ai and machine learning
05. install the fastai course requirements

Tutorials: Artificial Intelligence Course

This section contains answers to the questionnaire at the end of each lesson.

# fastai course
01. chapter 1: your deep learning journey q&a
02. chapter 2: from model to production q&a
03. chapter 3: data ethics q&a
04. chapter 4: under the hood: training a digit classifier q&a
05. chapter 5: image classification q&a
06. chapter 6: other computer vision problems q&a
07. chapter 7: training a state-of-the-art model q&a
08. chapter 8: collaborative filtering deep dive q&a

Tutorials: Artificial Intelligence Repositories

This section contains state-of-the-art repositories in the different subfields.

# repositories related to audio
01. raise audio quality using nu-wave
02. change voices using maskcyclegan-vc
03. clone voices using real-time-voice-cloning toolbox
# repositories related to images
01. achieve 90% accuracy using facedetection-dsfd

--

--

David Littlefield
Geek Culture

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