Desktop environment for Ubuntu 14.04 server

Desktop environment for Ubuntu 14.04 server This guide will tell you how to setup Desktop environment and a VNC server on an Ubuntu 14.04 server. The server will use a fast lightweight remote service – TightVNC package. After this, the next tutorial will explain how to connect to the server remotely and securely through SSH tunnel.
Prerequisites
  • Ubuntu 14.04 Server
  • Root Privilege

How to Install Desktop Environment and VNC server

First we have to get XFCE, TightVNC Packages. Do the following:
sudo apt-get update
sudo apt-get install xfce4 xfce4-goodies tightvncserver
In this tutorial, we will use demo as user. To add new user, do the following:
adduser demo
Giving permission to demo user:
visudo
Find the line # User privilege specification
Below the line root ALL=(ALL:ALL) ALL , paste the following line:
demo    ALL=(ALL:ALL) ALL
Save the changes by pressing ctrl+o and exit ctrl+x

Login to your user account that will be used to connect remotely.
su demo
Set VNC password
vncserver

Lets start configuring the VNC Server

vncserver -kill :1
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
nano ~/.vnc/xstartup
Insert this code:
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
Save it by pressing ctrl+o, then exit ctrl+x

Grant executable privilege:
sudo chmod +x ~/.vnc/xstartup
Create a VNC service file
sudo nano /etc/init.d/vncserver
Paste the following code. If you are using different user, please change the line 3.
#!/bin/bash
PATH="$PATH:/usr/bin/"
export USER="demo"
DISPLAY="1"
DEPTH="16"
GEOMETRY="1024x768"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -localhost"
. /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 "Stopping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;

restart)
$0 stop
$0 start
;;
esac
exit 0
Save it by pressing ctrl+o, then exit ctrl+x

Now make this code executable:
sudo chmod +x /etc/init.d/vncserver
sudo service vncserver start
Every time you restart your server, you have to run sudo service vncserver start

Some may wish to always do this manually just to save server memory. You can start the vnc service only when needed.

But if you wish to run the service automatically, the step is mentioned in the next tutorial: Remote Ubuntu Desktop Environment using VNC Client

In the next tutorial, we will explain how to connect to the server remotely and securely through SSH tunnel.

0 comments:

Copyright © 2012 My Linux Code