Last updated on 2019-12-23
Run graphical software without
When working within a machine that has no graphical interface, such as…
… you might still want the ability to run graphical software in certain cases. With Wine, for example, you’ll be able to reverse-engineer software developed for Windows. And with Selenium, which requires a browser, you can automate client-side actions on a website.
Let’s see how we can run graphical software on Debian without installing a full graphical environment.
The first piece is the virtual framebuffer X server, Xvfb, which emulates a display to which we can connect.
To install it, simply run
apt install xvfb.
Here’s how you can execute it:
export DISPLAY=:0 Xvfb -screen 0 640x480x16 &
Of course, you can choose a different display number and make adjustments to the screen resolution and depth.
VNC server and window manager
While the virtual framebuffer provides an emulated display, we need to connect to that display in order to view it.
This can be achieved with
x11vnc, a VNC server designed specifically to connect to existing displays.
x11vnc together are enough to display a barebones X window system. To make things friendlier, let’s also install
fluxbox, a light, fairly intuitive window manager:
apt install fluxbox x11vnc
Now, start both of them as follows:
fluxbox & # requires that the DISPLAY environment variable is declared x11vnc -usepw
-usepw flag will prompt you to create and store a password which must be entered by the client in order to connect. Optional, but recommended. Once the password is stored, future uses of
-usepw will retrieve the saved password instead of prompting for a new one.
Regardless of whether you set a password, the VNC connection will operate in cleartext. Please refer to these instructions on tunnelling x11vnc via SSH to protect the VNC traffic.
Now, with your VNC client of choice, connect to the target machine and you’ll be greeted with a desktop!
Naturally, if you decide to install a full X11-based graphical environment, you can still use
x11vnc to remotely view and control your machine – there’s just no need for
fluxbox at that point.
x11vnc has a handy
-find flag which tells it to automatically detect the active X display and use it for the VNC connection.
On a related note, after installing
kde-plasma-desktop on a virtual machine created with Vagrant using the debian/buster64 image, features like screen resizing and smart mouse/keyboard capture work out of the box. No need to install the VirtualBox Guest Additions.
x11vnc flag is
-viewonly. As the name implies, connecting clients will not be able to remotely control the target machine, but only be able to view the screen.
Lastly, you may have noticed that
x11vnc will exit after the client disconnects. In order to allow multiple connections, or persist the
x11vnc process, refer to the
-forever flags, respectively.