XFCE desktop environment with VNC on Ubuntu 24.04 VPS
This guide shows how to install the XFCE desktop environment and a VNC server on an Ubuntu 24.04 instance. Create an instance and connect to it over SSH to run the commands below. The available sizes and types are described in the guide to instance types.
Install XFCE and TigerVNC
sudo apt update
sudo apt install xfce4 xfce4-goodies
sudo apt install dbus-x11
sudo apt install tigervnc-standalone-server
Bonus: install Google Chrome (there is no browser by default)
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
Configure the VNC server
vncserver
Configure the xstartup file (it probably has to be created)
vi ~/.vnc/xstartup
and add the content below
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4
chmod +x ~/.vnc/xstartup
Run the VNC server as a systemd service
Create this file
sudo vi /etc/systemd/system/vncserver@.service
and add the content below (replace username)
[Unit]
Description=Start TigerVNC server at startup
After=syslog.target network.target
[Service]
Type=simple
User=username
Group=username
WorkingDirectory=/home/username
PIDFile=/home/username/.vnc/%H:590%i.pid
ExecStartPre=-/bin/sh -c "/usr/bin/vncserver -kill :%i > /dev/null 2>&1"
ExecStart=/usr/bin/vncserver -fg -depth 24 -geometry 1920x1080 -localhost no :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
sudo chmod +x /etc/systemd/system/vncserver@.service
sudo systemctl daemon-reload
sudo systemctl enable vncserver@1.service
vncserver -kill :*
sudo systemctl start vncserver@1
sudo systemctl status vncserver@1
Connect to the desktop
You can now connect to vnc://server_ip:5901 with a VNC client, or on macOS: Finder > Go > Connect to Server
If a firewall is active, in Hexabyte Cloud or on the server (for example ufw), TCP port 5901 must be open for you to connect.