Open Powershell or CMD as administrator:
- Enable WSL Feature
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
- Enable Virtualization
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart your device if needed, and make sure virtualization is enabled from bios
Download WSL2 Update Package: Download Package
Now Set WSL default to version 2 using the following command In CMD or Powershell
wsl --set-default-version 2
If you have already installed linux, update its version by:
wsl --set-version <linuxName> 2
Now, if everything done correctly wsl will be updated and set default for linux installations
Download the LTS version of Ubuntu from the Microsoft Store : Link
After downloading, open the Ubuntu app it'll install the linux subsystem. Follow the instructions and enter your unix username and password, when the linux is setup install the updates the system.
sudo apt update && sudo apt upgrade
We'll be using the Remote Desktop Protocol to connect to the display
sudo apt install xrdp ubuntu-gnome-desktop
During installation if prompted to configure display manager, select gdm
- Take a backup of the xrdp first
sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak
- Change the default rdp port to 3390 (optional)
sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini
- Change the resolution for better quality (optional)
The rdp connection will be local so why not better image quality
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
- Edit the xrdp window manager
sudo nano /etc/xrdp/startwm.sh
After opening the file go to the end of the file and comment out the last two lines like this and
gnome-session
under it.
# test -x /etc/X11/Xsession && exec /etc/X11/Xsession
# exec /bin/sh /etc/X11/Xsession
gnome-session
Clone the git repo given below and run it Link to Repo
git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
bash ubuntu-wsl2-systemd-script.sh
# Enter your password and wait until the script has finished
After that exit the shell using exit
command,
and restart the wsl using
wsl --shutdown
then
wsl
in CMD or PowerShell
sudo /etc/init.d/xrdp start
search for rdp in start menu
Use Computer as : localhost:3390
or localhost:3389
if you didn't change the port.
Then click Connect
You'll be asked for the unix username and password and keep the session type to xorg
That's it. Thank you for reading!