Augmenting your home network: Part II — Installing a Desktop environment on Ubuntu Server (VNC)

Freddie Lindsey
2 min readFeb 4, 2020

--

Using a Raspberry Pi to provide OpenVPN, Dynamic DNS, Local DNS, DHCP, and Advert-blocking

If you’re using a desktop version of Ubuntu which comes with a graphical user interface then accessing your desktop remotely is as simple as starting the screen sharing service on Ubuntu — you can find this in your settings.

If you want a different desktop environment, or you are on a server installation, you’ll want to follow the guide below, itself a shortened version of this guide from Digital Ocean.

$ sudo apt update 
$ sudo apt install xfce4 xfce4-goodies tightvncserver

Set a password to use when accessing your desktop over VNC..

$ vncpasswd

Create a ~/.vnc/xstartup file with the following content

#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &

We need to ensure the file is executable

$ chmod +x ~/.vnc/xstartup

Now we will create the system service that runs the VNC server and allows you to connect. Copy the following into /etc/systemd/system/vncserver@.service being sure to replace <USER> with your own username.

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=<USER>
Group=<USER>
WorkingDirectory=/home/<USER>
PIDFile=/home/<USER>/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1680x1050 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target

Now start the service, check its status and if all is well, enable it on boot.

$ sudo systemctl start vncserver@1
$ sudo systemctl status vncserver@1
$ sudo systemctl enable vncserver@1

You can now connect to your desktop over port 5901 (on a Mac you can hit CMD + K from Finder and type in vnc://<IP_ADDRESS_OF_SERVER>:5901 replacing as required). You should see something similar to mine if you choose the default config.

If you want to make your desktop a little bit more modern, you can install and configure the Arc theme and Moka icon theme. These are what I use.

Part III now available!

--

--