November 21, 2024

How to install a Linux Desktop and GUI on Windows Subsystem for Linux – WSL

In this tutorial, we explain maybe the simplest possible method for installing a Linux Desktop and Linux Graphics User Interface (GUI) in Windows Subsystem for Linux (WSL2). Here is a brief overview of the tasks that we will perform in this tutorial in order to install the desktop environment:

1. Install WSL2 and a desired Linux distribution. In our case, we will install Ubuntu 24.04

2. Install Tasksel: https://wiki.debian.org/tasksel
Tasksel is a software package that can be used to install the Linux Desktop Environment (Linux GUI)

3. Install xrdp. Xrdp is a software package that enables us to setup and use a remote desktop protocol. Xrdp is developed by Microsoft and it allows us to remotely access and interact with a server’s  graphics user interface. Xrdp is an abbreviation (acronym) for X Remote Desktop Protocol.

4. Use the Windows remote desktop connection to connect to the Linux Desktop Environment.

The YouTube tutorial is given below.

1. Install WSL2

If you do not have WSL2 installed on your system, you can install it as follows. Click on Start and search for Windows PowerShell. Open power shell in the administrator mode by doing a right click and by clicking on “run as administrator”. Check if WSL is already installed. You can do that by typing

wsl -l -v

If you see an output this means that WSL is installed. If not, to install WSL, you need to type

wsl --install

Then, after restarting the system, you will be able to use WSL. Note that with WSL there will be a default Linux Ubuntu version installed. We can change the default distribution and install any other supported distribution. We will install Ubuntu 24.04.

After you restart the system, open again Windows PowerShell in the administrator node. Type this

wsl -l -v

and you will see the list of installed distributions.

To list all available Linux distributions that can be run through WSL, type:

wsl --list  --online

We will install Ubuntu 24.04. To do that, type this:

wsl --install -d Ubuntu-24.04

Type exist to exit the installed linux distribution. We will manually start the installed distribution later on.

To list all installed distributions, type this

wsl -l -v

To start Ubuntu 24.04. Click on start and search for Ubuntu 24.04. By clicking on Ubuntu 24.04, Ubuntu session will start.

Another way to start Ubuntu is to go back to the power shell and to type

wsl -d Ubuntu-24.04

Let us use a graphical approach to start Ubuntu. Click on Start and search for Ubuntu 24.04, and start Ubuntu 24.04.

Then, update

sudo apt update
sudo apt upgrade

Install Tasksel, Select the Linux GUI Distribution, and Install Xrdp

To install and run tasksel, type this

sudo apt install tasksel
sudo tasksel

After starting tasksel, you will see this menu

Here, we will select GNOME, to do that use the keyboard arrows to navigate and press space to select, then, press TAB to move to OK and press enter.

After that, the installation process will start.

To install xrdp, type this

sudo apt install xrdp -y 

Confirm the installation with

sudo systemctl status xrdp

The status should be active (running). To exit this window, type this CTRL+C

If this program is not running, start it with

sudo systemctl start xrdp

Check the address of the Ubuntu Session and Start Remote Desktop Connection

To check the address, type this

ip a 

and copy the inet address. In our case, the inet address is 172.29.173.75

Then, start a Windows Remote Desktop Connection, by clicking on Start and searching for Remote Desktop Connection

Start the Remote Desktop Connection, and type the inet address in the Computer field.

Then connect.

Then, you will see this screen

and enter the username and password you used to start the Ubuntu 24.04. After you enter the username and password, the Ubuntu GNOME section will start