Install Ubuntu Desktop on Any Ubuntu Server
- Published on
- Reading time
- 2 min read
Turn a cloud server into a remote dev machine: install the Ubuntu desktop, boot into the GUI, and connect from any RDP client through XRDP.
Some developers want to use a cloud server as a personal computer, for fast development and remote use. It's a very good idea, but a cloud server ships without a desktop. How do you install an Ubuntu desktop on it?
It's easy with a few commands. In this guide you will install the Ubuntu desktop on an Ubuntu server, make the server boot into the graphical interface, and then set up XRDP so you can control it from any RDP client.
Note: written in October 2023; package names and defaults may differ on newer Ubuntu releases.
Install the Ubuntu desktop
- Start by installing tasksel:
sudo apt install -y tasksel
- Now you are ready to install
ubuntu-desktop:
sudo apt install -y ubuntu-desktop
- Cloud servers don't have a display by default, so the system boots to a text-only target. Set the graphical target so the GUI comes up:
sudo systemctl set-default graphical.target
And wow, it's working now.
Install XRDP for remote control
Having a desktop on the server is only useful if you can reach it. If you want remote control over RDP, follow these steps. The commands below change system files and the firewall, so run them as root or prefix them with sudo.
- Install xrdp:
sudo apt install xrdp -y
- Add the
xrdpuser to thessl-certgroup so xrdp can use SSL:
usermod -a -G ssl-cert xrdp
- Add these lines to the xrdp session script so the desktop session starts cleanly:
echo 'unset DBUS_SESSION_ADDRESS' >> /etc/xrdp/startwm.sh
echo 'unset XDG_RUNTIME_DIR' >> /etc/xrdp/startwm.sh
Note: the original post wrote Unset with a capital U; the shell command is lowercase unset, which is what is used here.
- xrdp is ready to connect. There is just one step left: allow port 3389, the RDP port, through the firewall:
ufw allow from 192.168.1.0/24 to any port 3389
ufw reload
This rule only accepts connections from the 192.168.1.0/24 network. Replace it with the address range you will actually connect from.
Connect
Now you can connect to your remote server with any RDP client and use it like a personal computer.