Tuesday, October 12
Shadow

Install Ubuntu GUI on Windows within WSL2

Prerequisites for WSL2

  • To run WSL2 on Windows 10, your x64 window system needs to be on version 1903 or higher, with build 18362 or higher.
  • Version 2004 or higher with build 19041 or higher is required for ARM64 systems.
  • To check your version and build number, press Windows logo + R, type winver, and click OK.
  • If you do not have the required version, just update your windows.

Install Windows Subsystem for Linux Using PowerShell (WSL2)

  • Open Windows PowerShell as Administrator.
  • Run command to enable WSL feature : dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
  • Run command to enable Virtual Machine feature : dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  • Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  • Restart your machine.

Install Windows Subsystem for Linux Using GUI (WSL2)

  • Type “Turn Windows features on or off” in search.
  • Select “Virtual Machine Platform” and “Windows Subsystem for Linux“. Click on OK.

WSL2 as default version

  • Open PowerShell and run the below command to set WSL2 as your default version.
  • wsl –set-default-version 2
  • It may ask you to update the kernel component. For that, you need to visit https://aka.ms/wsl2kernel
  • Copy the URL to any browser and download the latest Linux kernel update package.
  • Go to downloads and look for wsl_update_x64.msi
  • Double click on it and install the application.
  • Once it is installed, go back to PowerShell and run wsl –set-default-version 2 command again to set the default version of WSL to 2.

Download Ubuntu 20.04 from Microsoft Store

  • Click on Start and select Microsoft Store and search for Linux.
  • Select Ubuntu 20.04 and click on Get. It will start the download.
  • Select Launch, once download is complete.

Configure Ubuntu 20.04

  • Once you click on the Launch option, a new window will open for Ubuntu 20.04. Enter a new username and password.
  • You can run the command wsl -l -v in PowerShell to check the installed distribution of Linux.

Install GUI and RDP on Ubuntu 20.04

  • First thing, update and upgrade your Ubuntu 20.04 using the command: sudo apt update && sudo apt -y upgrade
  • Install RDP on Ubuntu 20.04 using command: sudo apt install xrdp
  • Next, we will install a lightweight graphical user interface using the xfce4 package. Command: sudo apt install -y xfce4
  • During the installation, it will ask you to select a default display manager. It is a program that provides graphical login capabilities for the X Windows System. We are going to use gdm3.
  • We will be adding some additional packages for better performance of the GUI. Command: sudo apt install -y xfce4-goodies
  • We are going to take a backup of xrdp configuration file. It is a good practice to have backups of the important configuration files. Command: sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.backup
  • Change the default port of 3389 to 3390. This step is just to make sure there are no conflicts with the port number if you are running more than one Linux distribution. Command: sudo sed -i ‘s/3389/3390/g’ /etc/xrdp/xrdp.ini
  • Now, we will set the parameters for screen resolution. Command: sudo sed -i ‘s/max_bpp=32/#max_bpp=32\nmax_bpp=128/g’ /etc/xrdp/xrdp.ini
  • sudo sed -i ‘s/xserverbpp=24/#xserverbpp=24\nxserverbpp=128/g’ /etc/xrdp/xrdp.ini
  • Save xfce4-session into a file called .xsession. Command: echo xfce4-session > ~/.xsession
  • Edit the xrdp startup script using command: sudo vi /etc/xrdp/startwm.sh
  • Comment out the very last two lines by putting a ‘#’ at the beginning of the line. Also, add two more lines and save the file.
  • Let’s start the xrdp service. Command: sudo /etc/init.d/xrdp start

Test the RDP with Ubuntu 20.04

  • Open Remote Desktop Connection from start.
  • In the Computer tab, type localhost:3390 and click on Connect.
  • Enter the username and password, which you have created earlier while configuring Ubuntu 20.04, and click on OK.
  • Finally, your Ubuntu 20.04 with GUI on Windows 10 is up and running.

3 Comments

  • Timothy Giblin

    This was very helpful, and the install ran without any issues whatsoever. Unfortunately, when I reach the last step I logged into Ubuntu 20.04 and nothing came up on the desktop. It was blank and the mouse was unresponsive. However the connection bar was at the top of my Ubuntu Desktop window, from which I could close the session. The Ubuntu Desktop was simply empty.

Leave a Reply

Your email address will not be published. Required fields are marked *

error

Enjoy this blog? Please spread the word :)