Raspberry Pi: Install VNC Server

Who his Raspberry Pi neither on its own display, still want to operate exclusively through a console, for the VNC Server is the right. VNC transmits the image of the graphical interface over the network, or port forwarding via the Internet. Alternatively, install Remote Desktop, and I on the front of- and cons of the two protocols at this point will not go into, as these are discussed elsewhere on the net detail. Below I will describe how to get a VNC server on his Raspberry Pi running.
requirement: installed Raspbian or similar distribution

Step 1
As VNC server for the Raspberry Pi, the Tight VNC package recommends, which can be installed via the package manager APT.

sudo apt-get install tightvncserver

Step 2

Now we install or preload, a small tool, which predicts, what programs and dependencies be opened next and this previously loads into RAM. This has the advantage, that the graphical user interface is much faster. For the operation of Raspberry Pis as pure server is not recommended preload.

sudo apt-get install preload

Step 3

Subsequently, we adjust a configuration of preload on, thus the use of the RAM is handled effectively.

sudo sed -i 's/sortstrategy = 3/sortstrategy = 0/g' /etc/preload.conf

Step 4

Now we start the VNC server for the first time. We are asked for a password to login. Then you can define, whether you want to define a view-only password, to permit a third party without issuing or changing the own password can, to look at the desktop of Raspberry Pis.

tightvncserver

Step 5

Now we stop the VNC server again, to make further facilities.

vncserver -kill :1

Step 6

We now create a startup script for the VNC server with the name vnc.sh, in which we enter the commands below. Use can replace 1280 × 720 by the desired resolution. However, I recommend without overclocking / overclocking over 1280 × 720 to go out, as this clearly goes to the Performance.

nano vnc.sh

 

#!/bin/sh
vncserver :1 -geometry 1280x720 -depth 24

Step 7
Now we give to the newly created file running rights.

chmod +x vnc.sh

If you want to let start VNC automatically booting the Raspberry Pis so we must take the following steps.

Step 8 (optional)
We create a start / stop script in /etc/init.d named vncboot and add the following startup script in this one. As in Step 6 the resolution can be adjusted again.

sudo nano /etc/init.d/vncboot

### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts VNC
# Description:
### END INIT INFO

export USER='pi'

eval cd ~$USER

# Check state
case "$1" in
start)
su $USER -c '/usr/bin/vncserver :1 -geometry 1280x720 -depth 24'
echo "Starting vncserver for $USER"
;;
stop)
pkill Xtightvnc
echo "vncserver stopped"
;;
*)
echo "Usage: /etc/init.d/vncboot {start|stop}"
exit 1
;;
esac

exit 0

 

Step 9 (optional)
Now we have to again give the file created additional rights.

sudo chmod 755 /etc/init.d/vncboot

Step 10 (optional)

Finally, we need to include the script in the Startup.

sudo update-rc.d vncboot defaults

completely finished! When you start your Raspberry Pis, the VNC server will be started automatically. If you want to operate the Raspberry Pi in this form, I can recommend you to overclock this, because the graphical interface will run much smoother. How to do this I explained in the article Overclocking / overclocking without warranty loss. can connect now to the VNC client using the port 5901. As client I can for Windows TightVNC Viewer, recommend the package tightvnc-java for Mac OS X and Linux RealVNC.