Tuesday, December 5, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  1] [ 0]  / answers: 1 / hits: 3158  / 1 Year ago, wed, august 31, 2022, 9:55:50

I am trying to install vnc on an x86_64 ubuntu 20.10 which is headless. I do NOT want Xfce, all of the tutorials for some inexplicable reason tell you to install xfce. I do NOT want to install this package as I already have the desktop manager: Gnome (default on Ubuntu).

As far as I can tell the guide on digital ocean seems to be the best except their xstartup is for xfce. I tried following and replaced xfce with gnome-session but I just get a grey screen and can't interact with anything.

could anyone please help me with this or point me in the right direction.


Edit: Here is my xstartup:

# Config requires following packages:
# gnome-panel nautilus gnome-terminal metacity



[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey

gnome-session &
gnome-panel &

metacity &
gnome-terminal &

I run vncserver via ssh on a remote machine using this:

$ vncserver

New 'X' desktop is media-server:1

Starting applications specified in /home/kevin/.vnc/xstartup
Log file is /home/kevin/.vnc/media-server:1.log

and here is the log:

04/02/21 10:40:28 Xvnc version TightVNC-1.3.10
04/02/21 10:40:28 Copyright (C) 2000-2009 TightVNC Group
04/02/21 10:40:28 Copyright (C) 1999 AT&T Laboratories Cambridge
04/02/21 10:40:28 All Rights Reserved.
04/02/21 10:40:28 See http://www.tightvnc.com/ for information on TightVNC
04/02/21 10:40:28 Desktop name 'X' (media-server:1)
04/02/21 10:40:28 Protocol versions supported: 3.3, 3.7, 3.8, 3.7t, 3.8t
04/02/21 10:40:28 Listening for VNC connections on TCP port 5901
Font directory '/usr/share/fonts/X11/75dpi/' not found - ignoring
Font directory '/usr/share/fonts/X11/100dpi/' not found - ignoring

(gnome-panel:123980): gnome-panel-WARNING **: 10:40:30.098: Failed to acquire bus name!
metacity-Message: 10:40:30.227: could not find XKB extension.

(metacity:123981): metacity-WARNING **: 10:40:30.232: Failed to create compositor: Missing composite extension required for compositing
Xlib: extension "X-Resource" missing on display ":1".

Here is what I get when I try to view the desktop:
VNC Connection

More From » vnc


Of course this is possible! There is nothing magical, Virtual display, desktop manager and VNC server are 3 pieces that must be put together correctly.

VNC server setup consists of 3 main steps:

  1. Xvfb - starting virtual display (can be used not only by GUI desktop, but could run apps like games or chromium directly in it)

export DISPLAY=:1
Xvfb $DISPLAY -screen 0 1024x768x16

  1. GUI session that connects to same Xvfb $DISPLAY and renders desktop there

For XFCE use this

sudo apt install xfce4 xfce4-goodies

xfce4-session # start xfce4

For default gnome use this:

gnome-shell --replace # start ubuntu gnome 

  1. xvnc server (tightvncserver or x11vnc). x11vnc way better, because Copy+Paste works out of box and Chromium apps work. tightvncserver does not work chromium apps. VNC server also connects to $DISPLAY and provides the access to clients outside. Do not run as sudo!

sudo apt install x11vnc

Password setup

x11vnc -storepasswd

x11vnc -display $DISPLAY -forever -loop -noxdamage -repeat -rfbauth /home/ubuntu/.vnc/passwd -rfbport 5900 -shared

Final script that you add to crontab crontab -e with @reboot /path/to/script.sh

Run scripts in background using & syntax


source /home/ubuntu/.bashrc
export DISPLAY=:1
Xvfb $DISPLAY -screen 0 2048x1536x24 &
xfce4-session &
x11vnc -display $DISPLAY -forever -loop -noxdamage -repeat -rfbauth /home/ubuntu/.vnc/passwd -rfbport 5900 -shared &

For default gnome

source /home/ubuntu/.bashrc
export DISPLAY=:1
Xvfb $DISPLAY -screen 0 2048x1536x24 &
gnome-shell --replace &
x11vnc -display $DISPLAY -forever -loop -noxdamage -repeat -rfbauth /home/ubuntu/.vnc/passwd -rfbport 5900 -shared &

[#1984] Friday, September 2, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 482
Total Questions: 104
Total Answers: 111

Location: South Korea
Member since Sun, Dec 25, 2022
1 Year ago
hentor questions
Fri, Feb 24, 23, 22:52, 10 Months ago
Sun, Sep 5, 21, 15:39, 2 Years ago
Sun, Jul 17, 22, 09:25, 1 Year ago
Tue, Jul 20, 21, 11:43, 2 Years ago