Installing the GNOME GUI on WSL2

author

By mathurinfarms

October 29th 2023

35

If you are a developer, you will probably end up using a Linux distro via WSL at some point in your career - and you will also come to the realization that using a CLI all the time is sometimes not the most efficient way to tackle things.

image

This tutorial will assume that you have WSL2 installed already. We will only cover the installation of the GNOME GUI. If you haven't installed WSL2 already, you can simply run the command wsl --install without the quotation marks in the command prompt. If you encounter any difficulties, this link is a great ressource.

Installing GNOME on WSL2

As of October 29th 2023, there are still issues with installing GNOME on WSl2, such as "Failed to restart acpid.service: Transport endpoint is not connected".

Most of the time, this issue that everyone seems to experience is very easy to solve, but you could have to unfortunately reinstall the Ubuntu distro as the following commands have to be run BEFORE trying to install GNOME.

If you're reading this, you probably already tried to install GNOME, so you may have to uninstall everything you did so far - for a begginer with Linux, the easiest way to go is basically to reinstall the entire Ubuntu distro. Unregister the Ubuntu distro using wsl --unregister Ubuntu, and reinstall Ubuntu. Note that this will erase any file that you have on your Ubuntu instance.

Once you have a clean install of Ubuntu in WSL2, run the two following lines of code one after another:First line: sudo apt purge -y acpid acpi-support modemmanagerSecond line: apt-mark hold acpid acpi-support modemmanager

Once those are done, reboot your WSL2 instance by running WSL --shutdown in the command prompt, and restart it by simply running ubuntu.

Finally, you should be able to run sudo apt install ubuntu-desktop gnome. This will take some time, so feel free to grab a snack in the meantime!

Installing XRDP

The installation process should've gone through without any error. Remember that to connect to the GUI, you must install XRDP, which is the remote desktop protocol for Linux. This will allow you to connect to GNOME directly using MSTSC, the Microsoft Terminal Services Client:

sudo apt install xrdp
sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini (this is to change the Linux RDP port, because already used by Windows)
sudo systemctl restart xrdp

Next, create a file called .xsessionrc in your Linux home directory with the following contents:

export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
export XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share:/usr/share:/var/lib/snapd/desktop
export WAYLAND_DISPLAY=
export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg

You should now be able to connect to your GNOME GUI using Remote Desktop by connecting to localhost:3390

If you have any questions, feel free to reach out to us via our LiveChat, or via email at [email protected]

mathurinfarms provides technology solutions for companies in various industries. If you think we can help your organization, feel free to contact us at [email protected]

Popular Tags :