I had to set this up the other day in order to connect to a remote server and use something that was only possible with a GUI. No cli unfortunately. This is how to do it.
First, we need to install VNC Server
$ sudo -i $ apt-get install gnome-core xfce4 firefox $ apt-get install vnc4server
The installed packages will look like this
$ dpkg -l | grep vnc ii vnc4server 4.1.1+xorg4.3.0-37ubuntu5 amd64 Virtual network computing server software
$ su - vncuser $ vncserver password: xxxx
Just in case backup the xstartup file.
$ cp ~/.vnc/xstartup ~/.vnc/xstartup.bak
Edit the configuration file.
$ vim ~/.vnc/xstartup #!/bin/sh unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS startxfce4 & [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic &
Kill vncserver with this command.
$ sudo vim /etc/init.d/vncserver #!/bin/bash unset VNCSERVERARGS VNCSERVERS="" [ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf prog=$"VNC server" start() { . /lib/lsb/init-functions REQ_USER=$2 echo -n $"Starting $prog: " ulimit -S -c 0 >/dev/null 2>&1 RETVAL=0 for display in ${VNCSERVERS} do export USER="${display##*:}" if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then echo -n "${display} " unset BASH_ENV ENV DISP="${display%%:*}" export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}" su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}" fi done } stop() { . /lib/lsb/init-functions REQ_USER=$2 echo -n $"Shutting down VNCServer: " for display in ${VNCSERVERS} do export USER="${display##*:}" if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then echo -n "${display} " unset BASH_ENV ENV export USER="${display##*:}" su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1 fi done echo -e "\n" echo "VNCServer Stopped" } case "$1" in start) start $@ ;; stop) stop $@ ;; restart|reload) stop $@ sleep 3 start $@ ;; condrestart) if [ -f /var/lock/subsys/vncserver ]; then stop $@ sleep 3 start $@ fi ;; status) status Xvnc ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" exit 1 esac
$ chmod +x /etc/init.d/vncserver
Set up some vnc configurations
$ mkdir -p /etc/vncserver $ vim /etc/vncserver/vncservers.conf VNCSERVERS="1:vncuser" VNCSERVERARGS[1]="-geometry 1024x768"
$ update-rc.d vncserver defaults 99
VNC Server listens on port 5901 by default. You can connect to it via a VNC Client with something like: