How to install VNC server
References
[1] https://hackernoon.com/installation-of-vnc-server-on-ubuntu-1cf035370bd3
[2] https://askubuntu.com/questions/800302/vncserver-grey-screen-ubuntu-16-04-lts
[3] https://www.ubuntu18.com/install-vnc-server-ubuntu-18/
Commands
Step-1
sudo apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal gnome-core gnome-session-flashback ubuntu-settings
Step-2
sudo apt-get install vnc4server
Step-3
sudo cp /usr/bin/vncserver /usr/bin/vncserver.bkp
Step-4-Manual change #1
sudo mcedit /usr/bin/vncserver
#After that find this line "# exec /etc/X11/xinit/xinitrcnn" and replace with
"# exec /etc/X11/xinit/xinitrcnn".
"gnome-panel &n".
"gnome-settings-daemon &n".
"metacity &n".
"nautilus &n".
"gnome-terminal &n".
Step-5-Manual change-2
Fill "~/.vnc/xstartup" with the following content:
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
Step-5-Manual change-alternative
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
export XKL_XMODMAP_DISABLE=1
export XDG_CURRENT_DESKTOP="GNOME-Flashback:Unity"
export XDG_MENU_PREFIX="gnome-flashback-"
gnome-session --session=gnome-flashback-metacity --disable-acceleration-check &
Step-6 Commands to work with vncserver (run this command from local user, not sudo)
Start server:
vncserver
Or start vncserver with specific display size
vncserver -geometry 1920x1080
In the case of several installed vncservers - tightvncserver has not problems.
Actually tightvncserver does not support XKEYBOARD extension. Workaround use another vncserer:
Installation cmdline: sudo apt-get install tigervnc-standalone-server
Launch cmdline: tigervncserver -localhost no -geometry 1920x1080
It does not support XKEYBOARD and has some OpenGL implementation
Step-7 Check listeting port
netstat -tulpn | grep vnc
Step-8 Allow income connections in iptables (maybe from root or user, or both)
iptables -I INPUT -j ACCEPT
Step-9
Kill vncserver with specifical display when needed
vncserver -kill :10