Launch VNC Server X session on startup

As root user, create a startup script

vim /etc/init.d/tightvncserver

Here is what the script should contain:

#! /bin/sh
# /etc/init.d/tightvncserver

# Carry out specific functions when asked to by the system
case "$1" in
    su root -c '/usr/bin/vncserver'
    echo "Starting VNC server "
    pkill vncserver
    echo "VNC Server has been stopped (didn't double check though)"
    echo "Usage: /etc/init.d/blah {start|stop}"
    exit 1

exit 0

Now make the script executable, start tightvncserver and enable it on startup:

chmod +x /etc/init.d/tightvncserver
service tightvncserver start
chkconfig tightvncserver on

Reboot and we’re done!


To run the session as another user, change the su root line to su username, where username is the user you want to run the session as.


Leave a Reply

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

Markdown is allowed in comments.