I would like to create a VNC server that runs gnome-shell environment, the same as the default UI in the console, separate from the console session (so that the console cannot see anything).

I tried vnc4server and tightvncserver, neither worked. No matter how I configured xstartup, gnome-session just won't run. I did manage to run Xfdm and gnome-panel in the same way. When I try to connect to the VNC server I get only grey screen. However I can confirm that the vnc server worked because I can run programs in it by setting DISPLAY and XAUTHORITY.

Is there a way to get ubuntu-desktop running in a new X session, separate from the console session? Preferably on a VNC server?

Steps I created the vnc server:

  1. Install a completely new Ubuntu 18.04 LTS Desktop.
  2. Install tightvncserver.
  3. Run vncserver to configure and kill it.
  4. Change ~/.vnc/xstartup and append:

    export STARTUP="/usr/bin/gnome-session --session=ubuntu --disable-acceleration-check" $STARTUP

  5. Run vncserver.

  6. Connect to the VNC server with any VNC client. Only grey screen is shown.
  7. Configure DISPLAY and XAUTHORITY and run gedit. The VNC session sees an incomplete gedit window.
  • Do you insist on using VNC? With xpra it should be easier to get there. – Sebastian Stark May 2 '18 at 18:28
  • If it's not VNC then I'd prefer a protocol that works over a slow Internet connection, and has clients on all operating systems - Android, Windows, etc. xpra seems to forward X connections which is not what I want. – vincent163 May 2 '18 at 23:40

Finally I found the solution.

The Gnome session doesn't seem to work on VNC X servers, but an Xvfb will work. The idea is to create an Xvfb for the session and use x11vnc for VNC:

Xvfb :1 -screen 0 1280x720x24

Then spawn GNOME environment:

DISPLAY=:1 gnome-shell --replace

Finally use x11vnc to create an VNC server for Xvfb:

x11vnc -display :1
  • Is there a way to do this in xstartup or something like that? – dazza5000 May 8 at 0:00

Make sure that you unset the DBUS_SESSION_BUS_ADDRESS at the beginning of the xstartup script.

Here is a snip of mine that have gnome-session started properly. However, the only issue so far is that the color scheme of the terminal is not properly applied, but VNC runs fine :)

if [ -e "$HOME/.Xresources" ]
    xrdb "$HOME/.Xresources"

if [ "GNOME" = "$MODE" ]
    if which gnome-session > /dev/null
        gnome-session --session=ubuntu &
  • MODE=" should be MODE="" , UN-terminated quotes. syntax error. – Dan Sep 27 '18 at 5:27
  • which vnc server are you using ? I tried your script with tightvnc and I can see only a screen without anything on it. – Cristiano Apr 24 at 2:04
  • I am using tigervnc-v1.9.0. – twang Apr 25 at 3:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.