Raspberry Pi: How to install a VNC server

21 Jun 2013
21. Juni 2013

For those, who, like me, want to operate the Raspberry Pi neither on a display, nor with a console, the VNC server is just right. VNC broadcasts the view of the graphical user interface through the network, or with port forwarding also through the internet. Hereinafter I will describe how you make a VNC server run on your Raspberry Pi.

Requires Raspbian or a similar Debian distribution

Step 1 

As VNC-Server for the Raspberry Pi, the Tight VNC package is recommended. You can install it with apt-get .

sudo apt-get install tightvncserver

Step 2 

Now we install preload, a little tool, that predicts which programms and pakage dependences will be used next and loads them into the RAM. This gives us the advantage, that the graphical user interface will run significantly faster. If you really want to use your Raspberry Pi as a server, I will not recommend preload.

sudo apt-get install preload

Step 3 

Afterwards we adjust the configuration of preload, so the RAM is used more 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 will be asked for a login password. Here you can set a View Only password, that allows third parties to watch the desktop of the Raspberry Pi without changing or telling your own password.

tightvncserver

Step 5 

Now we stop the VNC server, to do some further adjustments.

vncserver -kill :1

Step 6 

We create a startscript for the VNC-Server and call it vnc.sh, in that we enter the commands below. 1280×720 can be replaced by the desired resolution. However I do not recommend choosing a higher resolution than 1280×720 without overclocking.

nano vnc.sh

Step 7 

Now we make the just created file runnable.

chmod +x vnc.sh

Step 8 (optional) 

First we have to login as root with the following command.

sudo bash

Step 9 (optional) 

Again we create a new file, this time in the directory /etc/init.d with the name vncboot and enter the following startscript into it. The resolution can be adjusted, like in Step 5.

sudo nano /etc/init.d/vncboot

Step 10 (optional) 

Now we have to give the created file more rights. We can do so with the command below.

chmod 755 /etc/init.d/vncboot

Step 11 (optional) 

Now we have to make the script launched during the bootprocess. If the next command is followed by the output update-rc.d: error: unable to read /etc/init.d//etc/init.d/vncboot, step 12 has to be done. Otherwise it can be skipped!

update-rc.d /etc/init.d/vncboot defaults

Step 12 (optional, see Step 11) 

To solve the problem from Step 11, we run the following code:

update-rc.d vncboot defaults

Finally done! The VNC server will now automatically be launched, when the Raspberry Pi starts. If you want to use your Raspberry Pi in this form, I will recommend you to overclock it, because it makes the graphical user interface run signigicantly faster. You can connect through the port 5901.

Source of the startscript: http://myraspberrypiexperience.blogspot.co.uk/2012/08/start-vnc-automatically.html

 

This is a translation of Jans german article VNC Server installieren.

5 Antworten
  1. charudatt says:

    Great, I always learn a lot of stuff about Linux from your articles. Thank you for such good explanation.

    Request: Can you do an article on OMXPlayer. Its features and how to control it remotely.

    Thank you very much.

    Antworten
  2. Jörg H. says:

    Hallo Jan,

    vielen herzlichen Dank für Deine großartige Hilfe beim Laufenlernen mit dem Raspberry PI.
    Du schreibst wirklich gute und einfach nachvollziehbare Anleitungen.

    Zu Deiner VNC-Anleitung habe ich eine Frage: Gibt es eine Möglichkeit, via Webbrowser auf die VNC-Sitzung zuzugreifen? Meiner Meinung nach war das der Port 5801 und das Ganze lief wohl mittels Java. Laut ‘netstat -nptl’ lauscht mein VNC-Server auf den Ports 5901 und 6001. Auf allen drei genannten Ports bekomme ich aber keine Verbindung via Webbrowser. Hast Du da evtl. noch Informationen?

    Viele Grüße und Dank für Deine großartig Arbeit
    Jörg

    Antworten
    • Jan Karres says:

      Schön zu hören, denn das ist genau das Ziel, welches ich mit meinen Anleitungen verfolge.

      Meines Wissens nach ist der Port 5800 bzw. 5801 von VNC prinzipiell belegt und hat nichts mit einem spezifischen Web Viewer zu tun. Diesen denke ich musst du zusätzlich installieren, wobei ich, mangels Bedarf, nicht weiß was da gut ist und was weniger, sodass ich hier auch keinen Tipp geben kann.

      Antworten

Hinterlasse eine Antwort

Kommentar verfassen

JanKarres.de © 2007-2014