ANNEX: VNC server and viewer

VNC server alternatives in Ubuntu

TightVNC in Ubuntu 14.04

VNC4server in Ubuntu 14.04

VNC4server is the one installed in RASPEX Ubuntu 14.04.

Simply start it with the command:

vncserver

That will tell you the local URL (raspberry) and display number (2).

X11VNC server in Raspberry Pi & Odroid with Ubuntu 14.04

UPDATE install in Ubuntu 16.04: http://c-nergy.be/blog/?p=8984
UPDATE install in Ubuntu 16.04: http://www.wolffhaven45.com/blog/linux/x11vnc-server-installation-ubuntu-16-04-xenial-xerus/

Install and configure

sudo apt-get install x11vnc

Odroid runs in his original Ubuntu Trusty image X11VNC server

http://tecadmin.net/setup-x11vnc-server-on-ubuntu-linuxmint/

This tutorial allows you to auto-start the VNC server on boot http://www.cubieforums.com/index.php?topic=2515.0

Create "startvnc.sh" in /home/pi/

#! /bin/sh
x11vnc -usepw -forever -display :0 -geometry 1920x1080

The option -usepw will make mandatory to enter the password (see below how to set ii).

And make it executable:

chmod u+x startvnc.sh

Create "VNC Autostart" in home/pi/.config/autostart naming the files as vnc-autostart.desktop

[Desktop Entry]

Name=VNC Autostart
Exec=/home/pi/startvnc.sh
Type=Application
Terminal=true

And make sure that this script is owned by pi user, as well as startvnc.sh
Adafruit tutorial

And these commands show you how to manually access all the commands you may execute 

# Set a password
mkdir ~/.x11vnc
x11vnc -storepasswd <em>password</em> ~/.x11vnc/passwd
# Launch display 0(access port 5900)
x11vnc -display:0

If you need to stop the server: 

x11vnc -R stop
# Or specifying a display
x11vnc -display&nbsp;:0 -R stop
# And start it again
x11vnc -forever -display :0

http://unix.stackexchange.com/questions/115107/is-there-a-shutdown-resta...

And for starting it again using the script:

./startvnc.sh

TightVNC in Raspbian

https://www.raspberrypi.org/documentation/remote-access/vnc/

sudo apt-get install tightvncserver
tightvncserver

Start a VNC server from the terminal. This example starts a session on VNC display one (:1) with full HD resolution:

vncserver :1 -geometry 1920x1080 -depth 24

Note that since by default an X session is started on display zero, you will get an error in case you use :0

Since there are now two X sessions running, which would normally be a waste of resources, it is suggested to stop the displaymanager running on:0 using

service lightdm stop

Now, on your computer, install and run the VNC client:

sudo apt-get install xtightvncviewer

Otherwise, TightVNC is downloadable from tightvnc.com

AUTOMATION AND RUN AT BOOT

You can create a simple file with the command to run the VNC server on the Pi, to save having to remember it:

  • Create a file containing the following shell script vnc.sh:

#!/bin/sh
vncserver :1 -geometry 1920x1080 -depth 24 -dpi 96
  • Make the file executable:

chmod +x vnc.sh
  • Then you can run it at any time with:
./vnc.sh

To run at boot:

sudo su
cd /etc/init.d/

Create a new file here containing the following script vncboot:

#! /bin/sh
# /etc/init.d/vncboot

### BEGIN INIT INFO
# Provides: vncboot
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC Server at boot time
# Description: Start VNC Server at boot time.
### END INIT INFO

USER=pi
HOME=/home/pi

export USER HOME

case "$1" in
 start)
  echo "Starting VNC Server"
  #Insert your favoured settings for a VNC session
  su - $USER -c "/usr/bin/vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565"
  ;;

 stop)
  echo "Stopping VNC Server"
  /usr/bin/vncserver -kill :1
  ;;

 *)
  echo "Usage: /etc/init.d/vncboot {start|stop}"
  exit 1
  ;;
esac

exit 0

Make this file executable:

chmod 755 vncboot

Enable dependency-based boot sequencing:

update-rc.d lightdm remove
update-rc.d vncboot defaults

If enabling dependency-based boot sequencing was successful, you will see this:

update-rc.d: using dependency based boot sequencing

Reboot your Raspberry Pi and you should find a VNC server already started.