If you’re running a server or a virtual machine with CentOS Stream 9 and you want to add a graphical user interface (GUI), installing the GNOME desktop environment is a great option. Additionally, you may want to access the GUI remotely using XRDP. In this guide, we’ll cover the steps to install the GNOME desktop and set up XRDP for remote desktop access. We’ll also go over how to uninstall these components if you no longer need them.
📋 Prerequisites
Before we begin, make sure your system is up to date:
sudo dnf update -y
🖥️ Installing GNOME Desktop Environment
CentOS Stream 9 doesn’t come with a desktop environment by default, so you’ll need to install it manually.
- Step 1: Install GNOME Desktop
sudo dnf groupinstall "Server with GUI" -y
- Step 2: Set the default target to graphical (this will boot your system into the graphical interface by default)
sudo systemctl set-default graphical.target
- Step 3: Reboot your system to apply the changes
sudo reboot
Once your system restarts, you should be greeted with the GNOME login screen.
🔐 Installing XRDP for Remote Desktop Access
XRDP is an open-source implementation of the Microsoft RDP (Remote Desktop Protocol) that allows you to control a remote system’s desktop environment.
- Step 1: Install the EPEL repository
sudo dnf install epel-release -y
- Step 2: Install XRDP
sudo dnf install xrdp -y
- Step 3: Start and enable the XRDP service
sudo systemctl enable xrdp --now
- Step 4: Configure the firewall to allow RDP connections
sudo firewall-cmd --add-port=3389/tcp --permanent sudo firewall-cmd --reload
🔄 Associating XRDP with GNOME Desktop Environment
To ensure XRDP uses the GNOME desktop, you need to create an .xsession
file in your home directory with the following command:
echo "gnome-session" > ~/.xsession
Then, restart the XRDP service:
sudo systemctl restart xrdp
Now you can connect to your CentOS Stream 9 system using any standard RDP client by entering the server’s IP address.
❌ Uninstalling GNOME and XRDP
If you decide to uninstall GNOME and XRDP, follow these steps:
- Step 1: Remove GNOME Desktop
sudo dnf groupremove "Server with GUI" -y
- Step 2: Remove XRDP
sudo dnf remove xrdp -y
- Step 3: Remove the EPEL repository if it’s no longer needed
sudo dnf remove epel-release -y
- Step 4: Reset the default target to multi-user (text-based)
sudo systemctl set-default multi-user.target
- Step 5: Reboot your system
sudo reboot
After these steps, your system will return to its previous state without the GNOME desktop environment and XRDP.