VNC X11 session on Ubuntu 12.04 server without monitor or graphics card

By on

In doing so I felt there was no need to put a graphics card in the system. But I still wanted to vnc into the system, get a remote X11 session. Without any graphics card whatsoever you need vnc4server for that (or an NX server, but for internal purposes VNC would do just fine)

Start by becoming root

sudo -s

Now we'll install the server itself

apt-get install vnc4server

We also need a window manager, I'll choose for XFCE's. That might be a little too heavy for you, so you can choose something else like openbox or ratpoison. As long as you've got a window and session manager

apt-get install xfwm4 xfce4-session

I prefer the service to start automatically, so we'll create an upstart script for that.

nano /etc/init/vnc-server.conf

And pase this content in it. Replace "skerit" with your own username. Replace "1024x768" with your preferred resolution.

# vnc-server.conf

start on runlevel [2345]
stop on runlevel [016]

post-start script
        su skerit -c '/usr/bin/vnc4server :0 -geometry 1024x768'
end script

post-stop script
        su skerit -c '/usr/bin/vnc4server -kill :0'
end script

#End of File

Before actually starting this script, we have to run it ourselves in order to set up the password.
Unfortunately, this password must be at least 6 and at most 8 characters long.
Again: replace "skerit" with your own username.

su skerit -c 'vnc4server :0 -geometry 1024x768'

After this it'll tell you it has created several files that we'll need to edit:

New 'barabas:0 (skerit)' desktop is barabas:0

Creating default startup script /home/skerit/.vnc/xstartup
Starting applications specified in /home/skerit/.vnc/xstartup
Log file is /home/skerit/.vnc/barabas:0.log

Now we need to add something to that newly created xstartup script in order for it to actually start xfce4.
This should be the new content of xstartup:


[ -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 &
startxfce4 &

Now all you need to do is start the newly created service:

start vnc-server

And now you can connect to it form your favorite vnc client.


Hi, if this solution is suppose to work on a VPS using openvz? from another website: You can’t start X like this in container-based virtualization like OpenVZ i follow the, tut, i have xorg insalled, VNC start correctly, but got a grey screen. i try to run :~# startxfce4 /usr/bin/startxfce4: Starting X server X.Org X Server 1.12.4 Release Date: 2012-08-27 X Protocol Version 11, Revision 0 Build Operating System: Linux 3.16.0-4-amd64 x86_64 Debian Current Operating System: Linux 21de003583 2.6.32-042stab094.7 #1 SMP Wed Oct 22 12:43:21 MSK 2014 x86_64 Kernel command line: quiet Build Date: 09 February 2015 09:46:52AM xorg-server 2:1.12.4-6+deb7u6 (Julien Cristau ) Current version of pixman: 0.26.0 Before reporting problems, check to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/var/log/Xorg.0.log", Time: Mon Mar 23 23:57:38 2015 (==) Using config file: "/etc/X11/xorg.conf" (==) Using system config directory "/usr/share/X11/xorg.conf.d" Fatal server error: xf86OpenConsole: Cannot find a free VT: Invalid argument Please consult the The X.Org Foundation support at for help. Please also check the log file at "/var/log/Xorg.0.log" for additional information. Server terminated with error (1). Closing log file. xinit: giving up xinit: unable to connect to X server: Connection refused xinit: server error someone have idea?
I setup a mint 15 xfce to launch x11vnc on startup. So its the reverse of the sequence you setup. Mine doesnt launch mdm/X becase the hdmi port is disconnected and so it fails. So you think if I launch x11vnc first and then call mdm/XFCE it will work? or do I need xvfb as well for that? Thanks
Thanks a lot, was exactly what I was looking for!
Great post! Thank you very much.
i just wanted know if there is an option for boot with another resolution, thanks...
Thanks for a great tutorial, however is there a way to use the Gnome desktop in place of XFCE, alas I'm not a big fan of XFCE. Thanks again Andy
submit error done Busy
Jelle De Loecker