Useful Snippets

Welcome!


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 Unwanted.cloud

RSS Latest posts from my personal blog


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
  start)
    su root -c '/usr/bin/vncserver'
    echo "Starting VNC server "
    ;;
  stop)
    pkill vncserver
    echo "VNC Server has been stopped (didn't double check though)"
    ;;
  *)
    echo "Usage: /etc/init.d/blah {start|stop}"
    exit 1
    ;;
esac

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!

Note

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.

Source

Full-stack impostor syndrome sufferer & Software Engineer at Schibsted Media Group

Comments 0
There are currently no comments.