I’ve had some trouble setting up TightVNC on Raspbian, but after 2-3 fresh installs of the OS and a couple of hours of frustration, I finally managed to make TightVNC boot on startup.

Original Tutorial

This is the tutorial I followed: https://elinux.org/RPi_VNC_Server
Following is the modified version, which worked for me.

My Steps

Install TightVNC

$ sudo apt-get install tightvncserver

Set the login password:

$ sudo vncserver

Setup the autostart script:

$ sudo pcmanfm

When the file manager starts, go to /etc/init.d/ and create a new file called vncboot and paste the following content in the file and save:

#!/bin/sh
### 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=root
HOME=/root
 
export USER HOME
 
case "$1" in
 start)
   echo "Starting VNC Server"
   #Insert your favoured settings for a VNC session
   sudo /usr/bin/vncserver :1
   ;;
 
 stop)
   echo "Stopping VNC Server"
   sudo /usr/bin/vncserver -kill :1
   ;;
 
 *)
   echo "Usage: /etc/init.d/vncboot {start|stop}"
   exit 1
   ;;
esac
 
exit 0

Set execute permissions for the startup script:

$ sudo chmod 755 /etc/init.d/vncboot

Make the script run on startup:

$ sudo update-rc.d /etc/init.d/vncboot

If the previous command displays:

update-rc.d: error: unable to read/etc/init.d//etc/init.d/vncboot

then run:

$ sudo update-rc.d vncboot

You should see the following text when the command succeeds:

update-rc.d: using dependency based boot sequencing

Reboot and try to connect.


0 Comments

Leave a Reply

Avatar placeholder

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