In this article, we will have explained the necessary steps to install and configure VNC on Ubuntu 18.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
Virtual Network Computing (VNC) is a graphical desktop sharing system that allows you to use your keyboard and mouse to remotely control another computer.
Install VNC on Ubuntu
Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.
sudo apt update sudo apt upgrade
Step 2. Install Desktop Environment.
Now install Xfce4 and VNC server. Press y and ENTER if prompted to install:
sudo apt install xfce4 xfce4-goodies tightvncserver
Step 3. Configure VNC Server.
Now that the VNC server is installed the next step is to run the vncserver command which will create the initial configuration and set up the password. Do not use sudo when running the following command:
vncserver
You will be asked to enter a password. Generate a password 8 chars long, any longer and it will be truncated. You will also be asked if you want a view-only password where the user can only view and not control the remote server. You can skip this if you don’t require it.
VNC Server should now be running:
xauth: file /home/john/.Xauthority does not exist New 'X' desktop is ubuntu_server:1 Creating default startup script /home/linuxtips/.vnc/xstartup Starting applications specified in /home/linuxtips/.vnc/xstartup Log file is /home/linuxtips/.vnc/ubuntu_server:1.log
We now need to edit the xstartup file. Before doing so, kill VNC service:
vncserver -kill :1
Back up xstartup file:
cp ~/.vnc/xstartup ~/.vnc/xstartup.bak
Edit xstartup file:
nano ~/.vnc/xstartup
Add the following to the bottom of the file:
startxfce4 &
Now make the xstartup file executable:
sudo chmod +x ~/.vnc/xstartup
Now start vncserver again:
vncserver
Step 4. Connecting to CentOS Desktop via VNC Client.
In this example we’ll be using TigerVNC. Open your VNC viewer, enter localhost:5901 and click on the Connect button.
That’s all you need to do to install VNC on Ubuntu 18.04. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.