RaspberryPi 05: Remote Desktop

UPDATE:

This article is out of date, RealVNC is now installed on Raspbian, see this article for more info

(excerpt from page 27 of MRE-RPi book)

Often all you need to control your Raspberry Pi is an SSH connection, however sometimes it is useful to be able to remotely control your RPi using the mouse and seeing just what you would see on the screen of your RPi.

VNC (Virtual Network Connection) is a standard for doing just this. To use it, you have to install some software on your Pi. There are a number of VNC server applications, and the one we are going to use is called “tightvnc”.
We can install the VNC server software using the SSH connection that we established earlier.

**sudo apt-get install tightvncserver**
“vncserver :1 -geometry 1024×768 -depth 24”

on mac: open screen sharing
“vnc://192.168.10.70:5901”

Starting TightVNCServer on Boot

Having a remote desktop is extremely useful, but if we need to run the tightvncserver program on the Raspberry Pi each time we want to use the remote desktop, it would be extremely inconvenient. What we will do instead is set up tightvncserver so that it starts automatically each time the Raspberry Pi boots up.

To do this we are going to use a little bit of Linux cleverness. We’ll explain it as we go along, but be aware, some will find the explanations a little tiresome (if you’re already familiar) but I’m sure that there will be some readers who will benefit.

Our first task will be to edit the file /etc/rc.local. This file can contain commands that get run on start-up. If we look at the file we can see that there is already few entries in there;

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address

_IP=$(hostname -I) || true
if [ $_IP” ]; then
printf “My IP address is %sÄn” “$_IP”
fi

exit 0

We will add the following command into rc.local;
su – pi -c ‘/usr/bin/tightvncserver :1’

To do this we will edit the rc.local file with the following command;
sudo nano /etc/rc.local


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *