RDP - Bash script for installing the xfce graphical interface on Ubuntu 24.04 - 2026 - ENG
Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2026
Published: 2026-07-21
Short description: A Bash script to automatically install the XFCE desktop environment and xRDP server on a fresh Ubuntu 24.04. After execution you get a server ready for RDP connections with the XFCE desktop.
Script
#!/usr/bin/env bash
set -euo pipefail
#############################################
# Ubuntu 24.04 XFCE + xRDP Installer
#############################################
if [[ $EUID -ne 0 ]]; then
echo "Run the script as root."
exit 1
fi
export DEBIAN_FRONTEND=noninteractive
USERNAME="admin1"
echo "========================================"
echo " Ubuntu 24.04 XFCE + xRDP Installer"
echo "========================================"
echo
echo "[1/9] Updating system..."
apt update
apt -y upgrade
echo
echo "[2/9] Installing tasksel..."
apt install -y tasksel
echo
echo "[3/9] Installing XFCE desktop..."
if tasksel --list-tasks | grep -q "xubuntu-desktop"; then
echo "Using tasksel..."
tasksel install xubuntu-desktop
else
echo "Installing XFCE directly..."
apt install -y xfce4 xfce4-goodies
fi
echo
echo "[4/9] Installing xRDP..."
apt install -y xrdp xorgxrdp
echo
echo "[5/9] Creating user..."
if id "$USERNAME" >/dev/null 2>&1; then
echo "User $USERNAME already exists."
else
adduser --gecos "" "$USERNAME"
usermod -aG sudo "$USERNAME"
fi
echo
echo "[6/9] Configuring XFCE..."
echo "startxfce4" > /etc/skel/.xsession
chmod +x /etc/skel/.xsession
cp -f /etc/skel/.xsession /home/$USERNAME/.xsession
chown $USERNAME:$USERNAME /home/$USERNAME/.xsession
echo
echo "[7/9] Configuring xRDP..."
adduser xrdp ssl-cert || true
systemctl enable xrdp
systemctl restart xrdp
echo
echo "[8/9] Firewall..."
if command -v ufw >/dev/null 2>&1; then
ufw allow 3389/tcp || true
fi
echo
echo "[9/9] Verification..."
systemctl --no-pager --full status xrdp | head -15
IP=$(hostname -I | awk '{print $1}')
echo
echo "========================================"
echo "Installation complete!"
echo
echo "RDP:"
echo " IP: ${IP}"
echo " Port: 3389"
echo " Login: ${USERNAME}"
echo " Password: the one you set during user creation"
echo "========================================"
What the script does
The script performs 9 steps:
- System update —
apt update && apt upgrade. - Install tasksel — utility for installing Ubuntu meta-packages.
- Install XFCE — if the
xubuntu-desktopmeta-package is available, installs via tasksel; otherwise installsxfce4+xfce4-goodiesdirectly. - Install xRDP — packages
xrdpandxorgxrdp. - Create user — creates user
admin1(if it does not exist) and adds to thesudogroup. - Configure XFCE — writes
startxfce4into.xsessionso the desktop starts automatically on RDP connection. - Configure xRDP — adds user
xrdpto thessl-certgroup, enables and restarts the service. - Firewall — opens port 3389/TCP in UFW (if installed).
- Verification — prints the xrdp service status and the server IP address.
Usage
- Download the script onto a clean Ubuntu 24.04.
- Make it executable:
chmod +x script.sh - Run as root:
sudo ./script.sh - Wait for completion.
- Connect with any RDP client using the server IP address, port 3389, login
admin1.
Notes
- The script is designed for Ubuntu 24.04 and may not work on other versions or distributions.
- The password for user
admin1is set interactively during script execution (step 5). - If using a cloud server, make sure port 3389 is also open in the cloud provider's security group / firewall panel.
- XFCE was chosen as a lightweight environment — minimal memory consumption and good performance over RDP.
