1. Install the vnc4server package on Ubuntu
sudo apt-get update
sudo apt-get install vnc4server -y
2. Run vncserver and create a password for the VNC connection
vncserver
vncserver -kill :1
3. Install xfce4 as Desktop Environment
sudo apt-get install xfce4 xfce4-session
4. Open the ~/.vnc/xstartup file:
vim ~/.vnc/xstartup
#!/bin/sh
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
xfce4-panel &
xfsettingsd &
xfwm4 &
xfdesktop &
pcmanfm &
xfce4-terminal &
5. Save the configuration file and Start the VNC Server:
vncserver :1 -geometry 1920x1080 -depth 24
vncserver -kill :1
Use Gnome as Desktop Environment
Install ubuntu desktop or ubuntu minimal desktop base on your need
Repeat 3-5
3. Install gnome-session-flashback
sudo apt install gnome-session-flashback
4. vim ~/.vnc/xstartup
#!/bin/sh
autocutsel -fork
xrdb $HOME/.Xresources
xsetroot -solid grey
export XKL_XMODMAP_DISABLE=1
export XDG_CURRENT_DESKTOP="GNOME-Flashback:Unity"
export XDG_MENU_PREFIX="gnome-flashback-"
unset DBUS_SESSION_BUS_ADDRESS
gnome-session --session=gnome-flashback-metacity --disable-acceleration-check --debug &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &
5. Save the configuration file and Start the VNC Server:
vncserver :2 -geometry 1920x1080 -depth 24
vncserver -kill :2
Connect to vnc server from client
1. Use xfce4 as Desktop Environment
vnc://IP:1
2. Use Gnome as Desktop Environment
vnc://IP:2