How to install XFCE GUI on a Ubuntu 22.04 VPS with XRDP

Are you looking to remotely access the graphical user interface (GUI) of your Linux VPS? XRDP is an implementation of the Remote Desktop Protocol (RDP) that allows you to do just that.
This tutorial will walk you through the steps to install XRDP on a Linux VPS and access the GUI from a remote computer.

For this tutorial, we will go with a specific OS and GUI combination, but the idea behind every GUI installation is similar.
Our choice is Ubuntu 22.04 and xfce4.


In the end, you will have a VPS with a clean lightweight GUI, which looks great and runs great on low-tier servers as well.


Prep the VPS for the installation

Run the following commands and wait for them to finish:

apt-get update 
apt-get upgrade
Commands


If it asks for a resolver config: Keep settings
OpenSSH: Keep local version


Install the GUI and XRDP

  • As of Q4 2022, there is a known issue, which occurs during the xubuntu installation. To resolve this in advance, run the following:
apt-mark hold acpid acpi-support

Here is another set of commands, which you need to run.

apt install xubuntu-desktop
apt install xrdp
adduser xrdp ssl-cert
echo "startxfce4" > ~/.xsession
chmod +x ~/.xsession
systemctl restart xrdp.service
Commands

apt install xubuntu-desktop - Installs the GUI
apt install xrdp - Installs the xRDP
adduser xrdp ssl-cert - Adds the xrdp user to the ssl-cert group
echo "startxfce4" > ~/.xsession - Adds a "startxfce4" line to the .xsession file
chmod +x ~/.xsession - Adds executable permission to the .xsession file
systemctl restart xrdp.service - Restarts xRDP

Once these are completed, the basic GUI installation is completed and you can access the VPS via your RDP client.


How to add a new user‌                                                                                      

A new user can be added easily via the CLI with just another set of easy commands.

adduser newuser 
usermod -aG xrdp newuser
usermod -aG sudo newuser
Commands

adduser newuser - Creates a new user, with username newuser
usermod -aG xrdp newuser - Adds the new user to the xrdp group
usermod -aG sudo newuser -  Add the new user to the sudo group

Now switch to the new user, create a local ses file for it, and restart xrdp again.

su "newuser"
echo "startxfce4" > ~/.xsession
chmod +x ~/.xsession
systemctl restart xrdp

Now you will be able to log in to your GUI with your newly created user!