Using VNC to Operate a Desktop on Ubuntu 18.04

Frankie Fan
2 min readOct 16, 2020

--

Install ubuntu-desktop and VNC server

#Update the package sources
sudo apt-get update
sudo apt-get upgrade

#Install ubuntu-desktop
sudo apt-get install ubuntu-desktop

#Install VNC server
sudo apt-get install vnc4server

#Install gnome tools
sudo apt-get install gnome-core gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

#Fix the vi direction/delete key not working issue
sudo apt-get remove vim-common
sudo apt-get install vim

#Install net tools to test network
sudo apt install net-tools
netstat -tulpn

Launch VNC server and set access password

vncserver :1

#Telnet to test VNC server it's running
telnet localhost 5901

Connecting to VNC From your Desktop

Download and install the RealVNC Viewer on your laptop. Create a connection and specify your ubuntu address with the port 5901 and connect it, remember to input the password you just set.

Connecting to VNC From your Desktop

You may see the blank Gnome desktop after you connect to your VNC server.

Fix the VNC grey screen issue

You should modify the xstartup script to fix this issue.

vi .vnc/xstartup

xstartup content

#!/bin/sh

# 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 -nowin &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &

#These are newly added commands
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
gnome-panel &
gnmoe-settings-daemon &
metacity &
nautilus &
gnome-terminal &

Restart the VNC server after modification

vncserver -kill :1
vncserver

Connected to VNC From your Desktop

Now you can connected to your VNC server desktop

Originally published at https://hustakin.github.io.

--

--

Frankie Fan
Frankie Fan

Written by Frankie Fan

Researcher | Architect | Full-Stack | @hustakin

No responses yet