How To Install A GUI On WSL2 Using Tasksel And Access It Via Windows RDP

How To Install A GUI On WSL2 Using Tasksel And Access It Via Windows RDP

`tasksel` is a tool for Ubuntu and Debian-based systems that allows you to install multiple related packages as a coordinated “task” in a single step. It’s commonly used to install predefined collections of software, such as desktop environments. Below are detailed steps on how to use `tasksel` to set up a GUI on WSL2.

Using `tasksel` to Install a GUI on WSL2

1. **Install `tasksel`**:
First, make sure your package list is up-to-date and install `tasksel`:


sudo apt update -y && sudo apt upgrade -y
sudo apt install tasksel

2. **Run `tasksel`**:
Launch `tasksel` to see a list of available tasks, including desktop environments:

3. **Select a Desktop Environment**:
Use the arrow keys to navigate the menu, the space bar to select a desktop environment, and Enter to confirm your selection. Some common choices are:
– Ubuntu Desktop
– Xubuntu Desktop (Xfce)
– Lubuntu Desktop (LXDE)
– Kubuntu Desktop (KDE)

For a lightweight and efficient desktop environment, `Xubuntu Desktop` (Xfce) is a good choice.

4. **Install the Selected Desktop Environment**:
After selecting your preferred desktop environment, `tasksel` will automatically install it along with all necessary dependencies. This process can take some time, depending on your system and internet connection.

Setting Up XRDP for Remote Access

To access the installed desktop environment via Remote Desktop Protocol (RDP), follow these steps:

1. **Install XRDP**:
Install the `xrdp` package, which provides the necessary services for RDP:

2. **Start and Enable the XRDP Service**:
Ensure that the `xrdp` service starts automatically on boot:


sudo systemctl enable xrdp
sudo systemctl start xrdp

3. **Configure .xsession**:
Create or edit the `.xsession` file in your home directory to start your chosen desktop environment. For example, if you installed Xfce, you would use:


echo “startxfce4” > ~/.xsession

Connecting via Remote Desktop

1. **Allow RDP in Windows Firewall**:
Make sure the Windows firewall allows incoming connections on the default RDP port (TCP port 3389).

2. **Find WSL2 IP Address**:
Find the IP address of your WSL2 instance. You can find it by running:

3. **Connect Using Remote Desktop**:
On your Windows machine, open Remote Desktop Connection (you can search for it in the Start menu). Enter the IP address of your WSL2 instance (usually something like `172.18.x.x`) and click Connect.

4. **Log In**:
When prompted, enter your WSL2 username and password. You should now see the desktop environment you installed.

Example Commands Summary

Here’s a concise summary of the commands you need to run in your WSL2 terminal:
#Update package list and install tasksel


sudo apt update
sudo apt install tasksel

#Run tasksel to install a desktop environment

#(In tasksel, select a desktop environment such as Xubuntu Desktop)

#Install and configure xrdp


sudo apt install xrdp
sudo systemctl enable xrdp
sudo systemctl start xrdp

#Configure .xsession for Xfce


echo “startxfce4” > ~/.xsession

After completing these steps, use the Remote Desktop Connection application on Windows to connect to your WSL2 instance and enjoy your Linux desktop environment.

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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