Install GUI on Ubuntu Server and remote VNC

Ubuntu-logo-12.04_1

Hello guys. Today I received an Ubuntu VPS order form a client. He stated in the requirements that he needs remote access to the UI of the Server and since our Ubuntu based servers are being delivered only with SSH I had to manually install a User Interface and configure VNC server for him.

So I decided to capture some screenshots and publish the steps here as a tutorial. So to begin just connect to your ubuntu server through PUTTY (in this case my client VPS) as below.

Ubuntu Server Desktop and VNC

OK now we require to install “ubuntu-desktop, tightvncserver, xfce4, xfce4-goodies” packages! xfce is a super lite weight desktop environment and I choose it over Gnome because being so fast.

run following command in order to install all those packages:

# apt-get -y install ubuntu-desktop tightvncserver xfce4 xfce4-goodies

 

Let the installation finish! it might take some time depending your server connection and processor speed.

Ubuntu Server Desktop and VNC

Now use add user command and create a new user, we are going to give VNC access to this user later on.

SNAGHTML2894dde

When you created your user open /etc/sudoers file using nano and add your user right after root like the image below to ensure your user has all privileges.

SNAGHTML28b00c8

now change from root to the user you just created using “su – username” command like image below and run “vncpasswd” command to create a VNC password for this user through VNC server which we just installed.

SNAGHTML28e358d

if you faced exact outputs everything must be cool then. now we have to install the VNC server as a Service. create a file named vncserver in /etc/init.d/ directory by running:

#nano /etc/init.d/vncserver

 

and put following codes in there. (attention shahrooz here is my username! user the username you created in steps before instead of the word shahrooz.)

#!/bin/bash
PATH="$PATH:/usr/bin/"
export USER="shahrooz"
DISPLAY="1"
DEPTH="16"
GEOMETRY="1024x768"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
. /lib/lsb/init-functions

case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;

stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;

restart)
$0 stop
$0 start
;;
esac
exit 0

 

SNAGHTML2952e8c

now lets make sure that xfce is starting once vnc is connected! to do this edit “/home/shahrooz/.vnc/xstartup” and fill it with following line.

#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
startxfce4 &

 

SNAGHTML298d5a3

Use following command to update permissions and allow all users to start X server:

chown -R shahrooz. /home/shahrooz/.vnc && chmod +x /home/shahrooz/.vnc/xstartup
sed -i 's/allowed_users.*/allowed_users=anybody/g' /etc/X11/Xwrapper.config

 

SNAGHTML2a0d69d

Now make “/etc/init,d/vncserver” executable and start VNC server:

chmod +x /etc/init.d/vncserver && service vncserver start

 

Finally add vnc server to start up automatically on reboot with following command:

update-rc.d vncserver defaults

 

SNAGHTML2a31b89

connect to your ip:1 port through any vnc client you like! I am using RealVNC. You can use other alternatives such as TightVNC.

SNAGHTML2a5b825

That’s it! hope you enjoyed the tutorial.

Incoming search terms:

  • xfce tightvnc server setup
  • tightvncserver xfce4
  • vnc4server xfce ubuntu
  • gui for ubuntu server 14
  • tightvnc ui ubuntu
  • tightvnc server on xfce4
  • install PuTTY on XFCE Ubuntu
  • install gui and vnc ubuntu server
  • gui ubuntu server14 04
  • design and configuration step on wireless network in ubuntu server14 04

Leave a Reply