Credit https://computingforgeeks.com/how-to-install-vnc-server-on-ubuntu-18-04-lts/
Virtual Network Computing (VNC) is a technology which allows remote control of another computer using the Remote Frame Buffer protocol (RFB). In this guide, we’ll cover how to Install and Configure VNC Server on Ubuntu 18.04 LTS
VNC works in a client/server model. The VNC client is installed on the local computer while the VNC server is installed on the remote system to be managed. The server transmits a duplicate of the remote computer’s display screen to the viewer(client).
Install and Configure VNC Server on Ubuntu 18.04 LTS
Install VNC server on Ubuntu 18.04 by running the commands below in your terminal.
sudo apt update sudo apt -y install vnc4server
Step 2: Install Desktop Enviroment
Ensure you have a Desktop Environment installed on your Ubuntu 18.04. For this guide, we’ll install Xfce desktop environment.
sudo apt install xfce4 xfce4-goodies
You can choose to use other Desktop environments.
Step 3: Configure VNC Server
Once you’ve finished the installation of Desktop environment and VNC server. Configure VNC server on Ubuntu 18.04 LTS as follows.
Step 3: Configure VNC Server
Once you’ve finished the installation of Desktop environment and VNC server. Configure VNC server on Ubuntu 18.04 LTS as follows.
1.
Set a secure access password
Run the
vncpasswd
command to set password for your VNC server.$ vncpasswd Password: Verify:
When prompted, enter and verify your password to set.
2.
Start VNC server
Start VNC Server on Ubuntu 18.04 using the command:
$ vncserver :1 New 'ubuntu-01:1 (computingforgeeks)' desktop is ubuntu-01:1 Creating default startup script /home/computingforgeeks/.vnc/xstartup Starting applications specified in /home/computingforgeeks/.vnc/xstartup Log file is /home/computingforgeeks/.vnc/ubuntu-01:1.log
3.
Kill VNC Server
Kill VNC Server using the command:
$ vncserver -kill :1 Killing Xvnc4 process ID 20842
4.
Set VNC Server Desktop Environment
VNC configuration file is located on
~/.vnc/xstartup
. Edit it with your favorite text editor.sudo vim ~/.vnc/xstartup
Add the following line at the end of the file.
exec /usr/bin/startxfce4 &
Finally start VNC Server with ;
- Display number [1]
- Screen resolution [800×600]
- Color depth [24]
$ vncserver :1 -geometry 800x600 -depth 24 New 'ubuntu-01:1 (computingforgeeks)' desktop is ubuntu-01:1 Starting applications specified in /home/computingforgeeks/.vnc/xstartup Log file is /home/computingforgeeks/.vnc/ubuntu-01:1.log
Step 4: Connect to the VNC Desktop
You can connect to remote desktop using a VNC client and SSH tunneling. Create an ssh tunnel to VNC server using the following command
ssh@ -C -L 5901:127.0.0.1:5901
Then install vncviewer client
sudo apt install tigervnc-viewer
On Arch Linux, install it with:
sudo pacman -S tigervnc
Once your SSH tunnel is running, connect to
localhost:5901
using VNC client. When prompted for password, enter the password created during the VNC server configuration.
Once connected, you’ll see the default Xfce Desktop environment

Stop the current VNC server instance:
vncserver -kill :1
Create a systemd service unit file for managing VNC Server.
sudo vim /etc/systemd/system/vncserver@.service
Add:
[Unit] Description=Start TightVNC server at startup After=syslog.target network.target [Service] Type=forking User=computingforgeeks Group=computingforgeeks WorkingDirectory=/home/computingforgeeks PIDFile=/home/computingforgeeks/.vnc/%H:%i.pid ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1 ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i ExecStop=/usr/bin/vncserver -kill :%i [Install] WantedBy=multi-user.target
Don’t forget to replace computingforgeeks with your actual remote user username. Save the file and exit when done.
Reload systemd and start VNC
sudo systemctl daemon-reload sudo systemctl enable --now vncserver@1
Check status:
$ systemctl status vncserver@1 * vncserver@1.service - Start TightVNC server at startup Loaded: loaded (/etc/systemd/system/vncserver@.service; indirect; vendor preset: enabled) Active: active (running) since Wed 2018-12-05 11:32:50 PST; 7s ago Process: 24161 ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :1 (code=exited, status=0/SUCCESS) Process: 24154 ExecStartPre=/usr/bin/vncserver -kill :1 > /dev/null 2>&1 (code=exited, status=2) Main PID: 24168 (Xvnc4) Tasks: 63 (limit: 1110) CGroup: /system.slice/system-vncserver.slice/vncserver@1.service |-24168 Xvnc4 :1 -desktop ubuntu-01:1 (computingforgeeks) -auth /home/computingforgeeks/.Xauthority -geometry 1280x800 -depth 24 -rfbwait 30000 -rfbauth /home/v |-24174 vncconfig -iconic |-24176 /bin/sh /etc/xdg/xfce4/xinitrc -- /etc/X11/xinit/xserverrc |-24186 xfce4-session |-24189 /usr/bin/dbus-launch --sh-syntax --exit-with-session xfce4-session |-24190 /usr/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --session |-24194 /usr/lib/x86_64-linux-gnu/xfce4/xfconf/xfconfd |-24198 /usr/bin/ssh-agent -s |-24202 xfwm4 .....
You have successfully installed and configured VNC server on Ubuntu 18.04 server. Check other Ubuntu guides available in our website.