Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to set up a Raspberry Pi so that VNC starts on boot. Mostly from http://myraspberrypiexperience.blogspot.co.uk/p/setting-up-vnc.html

Starting VNC automatically on a Raspberry Pi

sudo apt-get install tightvncserver
vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565
  • Set up a password for access (optional)
sudo vi /etc/init.d/tightvncserver
  • Paste the contents of the file below (tightvncserver.sh) into this new file.
sudo chmod 755 /etc/init.d/tightvncserver
sudo update-rc.d tightvncserver defaults

Done.

### 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
# First configure the user you want to run this under - this will generally be pi, unless you've created your own users
export USER='pi'
eval cd ~$USER
# Check the state of the command - this'll either be start or stop
case "$1" in
start)
# if it's start, then start vncserver using the details below
su $USER -c '/usr/bin/vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565'
echo "Starting vncserver for $USER "
;;
stop)
# if it's stop, then just kill the process
pkill Xtightvnc
echo "vncserver stopped"
;;
*)
echo "Usage: /etc/init.d/vncserver {start|stop}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.