Setting up VNC (x11vnc) on Ubuntu 14.04 trusty and connecting from Windows

I like my VNC server to run only when I have actively started using my desktop. I often get lazy and wish to continue work from my bedside laptop.

If you would like to run x11vnc as a daemon use the alternate steps below

Running vnc server after logon:

Step 1> Setup a VNC Password File

$>x11vnc -storepasswd

After entering your password twice, the .vnc/passwd file will be created

Step 2> Setup x11vnc to run when you open up a terminal

open up your bashrc ($>nano ~/.bashrc) and add the following line

x11vnc -forever -bg -display :0 -rfbauth .vnc/passwd

Step 3> Download TightVNC viewer for windows and connect!

Running vnc server as a daemon

Step1: Run the following commands

$>sudo cp /etc/init.d/skeleton /etc/init.d/x11vncserver

$>sudo chmod 775 /etc/init.d/x11vncserver

$>sudo nano /etc/init.d/x11vncserver

Step2: Replace the corresponding lines in the file by this

DESC=”X11 VNC Server Service”
DAEMON_ARGS=”-bg -forever -display :0 -rfbauth /home/pr0t0s/.vnc/passwd”

Step3: Install x11vncserver as a daemon
update-rc.d x11vncserver defaults 97 03

Step4: start the service!

sudo service x11vncserver start

Step5: Download TightVNC viewer for windows and connect!