How to Install Ubuntu Desktop and Connect via RDP or VNC
This guide explains how to transform your Linux VPS into an Ubuntu Desktop with a graphical interface, and how to connect remotely via VNC or RDP.
Order a Serverโ
For comfortable Ubuntu Desktop use, HostMyServers offers several options:
- Performance VPS - Recommended for smooth usage
- NVMe VPS - Good value for money
- Eco Dedicated Servers - For optimal experience
- Performance Dedicated Servers - Maximum performance
Prerequisitesโ
- SSH access as root or user with sudo privileges
- Ubuntu Server 20.04, 22.04 or 24.04 installed
- Minimum 2 GB RAM (4 GB recommended)
- Minimum 20 GB free disk space
- Stable internet connection
Recommended Configurationโ
| Usage | RAM | CPU | Storage |
|---|---|---|---|
| Light usage | 2 GB | 2 cores | 20 GB |
| Standard usage | 4 GB | 2-4 cores | 40 GB |
| Heavy usage | 8 GB+ | 4+ cores | 60 GB+ |
Part 1: Installing Ubuntu Desktopโ
System Updateโ
Connect to your VPS via SSH and update the system:
sudo apt update && sudo apt upgrade -y
Installing the Desktop Environmentโ
Install Ubuntu Desktop:
sudo apt install ubuntu-desktop -y
Installation takes about 10 to 15 minutes depending on your server's power and internet connection. Many packages will be downloaded (about 2-3 GB).
Minimal Installation (Alternative)โ
If you prefer a lighter installation, you can install only the minimal GNOME desktop:
sudo apt install ubuntu-desktop-minimal -y
Or choose a lighter desktop environment like XFCE:
sudo apt install xubuntu-desktop -y
Or LXDE (very light):
sudo apt install lubuntu-desktop -y
Server Restartโ
Once installation is complete, restart your server:
sudo reboot
Part 2: Connecting via VNC (Recommended)โ
VNC offers better fluidity and a more optimized experience for Linux.
Installing TigerVNC Serverโ
sudo apt install tigervnc-standalone-server tigervnc-common -y
Configuring VNC Passwordโ
Configure the password for VNC connection:
vncpasswd
Answer the questions:
Password: [enter your password]
Verify: [confirm password]
Would you like to enter a view-only password (y/n)? n
VNC password is limited to 8 characters. Choose a strong password.
Configuring VNC Serverโ
Create a configuration file for startup:
mkdir -p ~/.vnc
nano ~/.vnc/xstartup
Add the following content:
#!/bin/bash
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec startxfce4 &
For GNOME (standard Ubuntu Desktop), use instead:
#!/bin/bash
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
export XKL_XMODMAP_DISABLE=1
exec /usr/bin/gnome-session &
Make the file executable:
chmod +x ~/.vnc/xstartup
Starting VNC Serverโ
Launch VNC server with remote access:
vncserver -localhost no
By default, VNC listens on port 5901 (display :1).
Check Statusโ
vncserver -list
Stop VNC Serverโ
vncserver -kill :1
Connecting to VNC Serverโ
-
Download a VNC client:
- Windows: RealVNC Viewer or TigerVNC
- macOS: RealVNC Viewer or built-in VNC client
- Linux:
sudo apt install tigervnc-vieweror Remmina
-
Connect to address:
SERVER_IP:5901 -
Enter the configured VNC password
Firewall Configuration for VNCโ
sudo ufw allow 5901/tcp
sudo ufw reload
Automatic VNC Startupโ
Create a systemd service to start VNC automatically:
sudo nano /etc/systemd/system/vncserver@.service
File content (replace YOUR_USER with your username):
[Unit]
Description=TigerVNC Server for %i
After=syslog.target network.target
[Service]
Type=forking
User=YOUR_USER
Group=YOUR_USER
WorkingDirectory=/home/YOUR_USER
PIDFile=/home/YOUR_USER/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -localhost no :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable vncserver@1.service
sudo systemctl start vncserver@1.service
Part 3: Connecting via RDP (Alternative)โ
RDP is convenient if you use Windows as the client is built-in, but less optimized for Linux.
Installing xrdpโ
sudo apt install xrdp -y
Configuring xrdpโ
Add the xrdp user to the ssl-cert group:
sudo adduser xrdp ssl-cert
Restarting xrdp Serviceโ
sudo systemctl restart xrdp
sudo systemctl enable xrdp
Checking Statusโ
sudo systemctl status xrdp
Firewall Configuration for RDPโ
sudo ufw allow 3389/tcp
sudo ufw reload
Connecting to RDP Serverโ
From Windowsโ
- Open "Remote Desktop Connection" (mstsc.exe)
- Enter your server's IP address
- Click "Connect"
- Enter your Linux username and password
From macOSโ
- Download Microsoft Remote Desktop from the App Store
- Add a new PC with your server's IP
- Connect with your Linux credentials
From Linuxโ
sudo apt install remmina remmina-plugin-rdp -y
Then launch Remmina and configure a new RDP connection.
Common RDP Troubleshootingโ
Black Screen After Connectionโ
If you get a black screen, edit the startwm.sh file:
sudo nano /etc/xrdp/startwm.sh
Add these lines before the last lines of the file:
unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR
Then restart xrdp:
sudo systemctl restart xrdp
Slow Sessionโ
To improve performance, reduce the resolution in RDP client settings or change color quality (16 bits instead of 32 bits).
VNC vs RDP Comparisonโ
| Criteria | VNC | RDP |
|---|---|---|
| Performance on Linux | โญโญโญโญโญ | โญโญโญ |
| Ease of installation | โญโญโญโญ | โญโญโญโญโญ |
| Built-in Windows client | โ | โ |
| Bandwidth | Medium | Low |
| Native security | Medium | Good |
| Recommended for | Daily use | Occasional access |
For regular Ubuntu Desktop use, we recommend VNC which offers better fluidity and better compatibility with the Linux environment.
Securing Connectionsโ
SSH Tunnel for VNC (Recommended)โ
To secure your VNC connection with an SSH tunnel:
- On your local machine, create the tunnel:
ssh -L 5901:localhost:5901 user@SERVER_IP
- Connect via VNC to
localhost:5901
This method encrypts the entire VNC connection.
Change VNC Portโ
For more security, you can use a custom port:
vncserver -localhost no :2
This will create a VNC server on port 5902.
Limit Access by IPโ
Configure UFW to only allow your IP:
sudo ufw delete allow 5901/tcp
sudo ufw allow from YOUR_IP to any port 5901 proto tcp
sudo ufw reload
Uninstallationโ
Uninstall VNCโ
sudo systemctl stop vncserver@1.service
sudo systemctl disable vncserver@1.service
sudo apt remove tigervnc-standalone-server tigervnc-common -y
rm -rf ~/.vnc
Uninstall RDPโ
sudo systemctl stop xrdp
sudo systemctl disable xrdp
sudo apt remove xrdp -y
Uninstall Ubuntu Desktopโ
sudo apt remove ubuntu-desktop -y
sudo apt autoremove -y
Troubleshootingโ
VNC Won't Startโ
- Check logs:
cat ~/.vnc/*.log - Check if port is already in use:
ss -tlnp | grep 5901 - Kill existing sessions:
vncserver -kill :1
Cannot Connectโ
- Check firewall allows the port:
sudo ufw status - Check service is running:
vncserver -list - Test connectivity:
nc -zv SERVER_IP 5901
Graphical Interface is Slowโ
- Reduce resolution in VNC/RDP client
- Use a lighter desktop environment (XFCE, LXDE)
- Increase VPS RAM
- Check your connection bandwidth
Keyboard Not Working Correctlyโ
For keyboard layout issues, install:
sudo apt install console-data keyboard-configuration -y
sudo dpkg-reconfigure keyboard-configuration
Then restart VNC server or xrdp.