Start TightVNC Server at Boot

4 posts
by pgix » Wed Jun 06, 2012 9:14 am
Hi All,

I got my Pi last week and am loving playing around on it. It's really my first time seriously using Linux, although I would consider myself a Windows "power user" and have used Cygwin (for hobby OS development). So far, I'm booting from a 4GiB SD card and have the rest of my system on an external USB hard drive which I can SAMBA in to from my Windows machine.

The thing I'm stuck with, is getting TightVNC server running at boot time without requiring me to login (i'm using the Arch Linux for ARM distro). I have followed various online tuts, but the ones I have found involve scripts which seem to run at login-time rather than boot time. Anything that I have found which starts the server at boot time involves editing scripts in "/etc/init.d" which Arch does not appear to have (although it does have "/etc/rc.d").

The situation so far, is that if I reboot the Pi, login via puTTY and start tightVNC, all is well. I get a nice view of lxde which runs surprisingly quickly (it surprised me, anyway!). If, however, I try the above without first logging in via puTTY, the Pi actively refuses the connection.

So, the question is: How do I get this server running correctly at boot time in Arch Linux without requiring manual login?

Posts: 34
Joined: Wed Jan 25, 2012 3:53 pm
by slacker » Wed Jun 06, 2012 8:02 pm
I've never used Arch, but I think you should have a file called /etc/rc.local this can be used to add any commands or scripts you want to run at boot time.
If you edit the file and add this to the end it should start the vncserver, I've tried it in Debian and it works anyway. If rc.local has a line saying "exit 0" at the end put the command before that or it won't get run.

Code: Select all
/usr/bin/sudo -u your_username vncserver

Any commands in rc.local are run as root, so sudo -u is used to make vncserver run as though you ran it using your normal username. Might be worth checking that sudo is in /usr/bin, you can do this by doing,
Code: Select all
which sudo

if it's somewhere else change /usr/bin/sudo to wherever it lives.
Posts: 33
Joined: Wed Dec 07, 2011 9:12 pm
by pgix » Thu Jun 07, 2012 6:19 pm

Spot on, thank you!

I had previously tried adding vncserver to rc.local, but had assumed that it doesn't work like that in Arch, because nothing seemed to happen.

Actually, my incorrect assumption was that sudo was automatically installed as a part of "core linux". Up until now, I have been either logging in as root or using "su" to run privileged commands. "pacman -Sy sudo" fixed this problem and I can now login to lxde via VNC without manually loging in through SSH.

Thanks again for your helpful post!
Posts: 34
Joined: Wed Jan 25, 2012 3:53 pm
by linda » Mon Jul 02, 2012 10:08 am
hello pgix
I was wondering about your word, did you mean that you need to connect your Archlinux to the server automatically when you connect?
Actually I am working on something like that right now
Posts: 1
Joined: Mon Jul 02, 2012 10:05 am