Useful Snippets


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at

RSS Latest posts from my personal blog

Most viewed posts

Subscribe to RSS feed

Launch VNC Server X session on startup

Stanislav KhromovStanislav Khromov

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.


Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
Twitter Profile
Visit my other blog

Comments 0
There are currently no comments.