Sunday, December 2, 2018

Configure the VNC Server on Ubuntu

VNC configuration file called xstartup in the .vnc folder under your home directory. 

We can modify some of the commands for the remote desktop.
When VNC is first set up, it launches a default server instance on port 5901. This port is called a display port, and is referred to by VNC as :1. VNC can launch multiple instances on other display ports, like :2:3, etc. When working with VNC servers, remember that :X is a display port that refers to 5900+X.
Because we are going to be changing how the VNC server is configured, we'll need to first stop the VNC server instance that is running on port 5901.

  • vncserver -kill :1

The output should look like this, with a different PID:


Killing Xtightvnc process ID 11535
Before we begin configuring the new xstartup file, let's back up the original.

  • mv ~/.vnc/xstartup ~/.vnc/xstartup.bak

Now create a new xstartup file with nano or your favorite text editor.

  • vim ~/.vnc/xstartup

Paste these commands into the file so that they are performed automatically whenever you start or restart the VNC server, then save and close the file.


xrdb $HOME/.Xresources
startxfce4 &
The first command in the file, xrdb $HOME/.Xresources, tells VNC's GUI framework to read the server user's .Xresources file. .Xresources is where a user can make changes to certain settings of the graphical desktop, like terminal colors, cursor themes, and font rendering. The second command simply tells the server to launch Xfce, which is where you will find all of the graphical software that you need to comfortably manage your server.
To ensure that the VNC server will be able to use this new startup file properly, we'll need to grant executable privileges to it.

  • chmod +x ~/.vnc/xstartup

Now, restart the VNC server.

  • vncserver

The server should be started with an output similar to this:


New 'X' desktop is

Starting applications specified in /home/i88ca/.vnc/xstartup
Log file is /home/i88ca

Featured Post

<b>Blockchain</b> Landscape and AI Renaissance