1

I have tightvnc installed and working on my Raspberry Pi. I intend to use the Pi via VNC from my Mac. Is there a way to auto start tightvnc when the Pi boots up as then I wont have to have a separate monitor, keyboard and mouse connected to the pi when it starts.

I have Raspbian installed from the latest NOOBS software.

0
2

You could write a script which starts tightvnc and copy it to /etc/services/ but you have to mark it executable with chmod 775 as example

Alternatively you could ssh into your pi and start tightvnc manually

1
  • 1
    Your suggestion for sshing to the pi and starting it manually works a treat
    – dmeehan
    Sep 10 '14 at 16:18
3
  1. Create the following new file /etc/init.d/tightvnc:

     #!/bin/sh
     ### BEGIN INIT INFO
     # Provides:          tightvncserver
     # Required-Start:    $local_fs
     # Required-Stop:     $local_fs
     # Default-Start:     2 3 4 5
     # Default-Stop:      0 1 6
     # Short-Description: Start/stop tightvncserver
     ### END INIT INFO
    
     # Set the USER variable to the name of the user to start tightvncserver under
     export USER='pi'
    
     eval cd ~$USER
    
     case "$1" in
       start)
         su $USER -c '/usr/bin/tightvncserver :1'
         echo "Starting TightVNC server for $USER "
         ;;
       stop)
         pkill Xtightvnc
         echo "Tightvncserver stopped"
         ;;
       *)
         echo "Usage: /etc/init.d/tightvnc {start|stop}"
         exit 1
         ;;
     esac
     exit 0
    

    Remember to change the USER variable (don't make it root!)

  2. Change the permissions so that the file can be executed:

     sudo chmod 755 /etc/init.d/tightvnc
    
  3. Make the script executed at boot time

     update-rc.d tightvnc defaults
    
  4. Reboot the RPi to check if it runs.

Sources: http://elinux.org/RPi_VNC_Server & http://www.penguintutor.com/linux/tightvnc

4
  • 2
    The above works, if you change: update-rc.d /etc/init.d/tightvnc defaults to: update-rc.d tightvnc defaults. Aug 13 '18 at 11:19
  • Why doesn't it work with the full path specified? Also, this would only work if the path to tightvnc is in $PATH Aug 13 '18 at 12:07
  • 1
    @Greenonline That's not how update-rc.d works. Read the first sentence of man update-rc.d: manpages.debian.org/jessie/sysv-rc/update-rc.d.8.en.html I don't know if it is smart enough to catch someone using an absolute path, if not, using one won't work, so best practice would be to not use one.
    – goldilocks
    Aug 13 '18 at 12:32
  • @goldilocks - ok, yeah, thanks. Wasn't thinking straight :-) Aug 13 '18 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.