LinuxCommandLibrary

xvfb-run

Run graphical applications without a display

TLDR

Run the specified command in a virtual X server

$ xvfb-run [command]
copy

Try to get a free server number, if the default (99) is not available
$ xvfb-run [[-a|--auto-servernum]] [command]
copy

Pass arguments to the Xvfb server
$ xvfb-run [[-s|--server-args]] "[-screen 0 1024x768x24]" [command]
copy

SYNOPSIS

xvfb-run [options] command [args...]

PARAMETERS

--auto-servernum
    Let xvfb-run choose a free server number instead of requiring one with -s.

--server-num=servernum
    Specify the server number to use (default is 99). If set to 'auto', it selects one automatically.

--server-args=args
    Pass additional arguments directly to the Xvfb server.

--wait-exit
    Wait for the Xvfb server to exit before exiting. Useful for debugging.

--listen=transports
    Specify the transports Xvfb should listen on. Example: --listen=tcp,unix.

--auth-file=filename
    Specify an alternate X authority file.

--help
    Display this help message and exit.

--version
    Output version information and exit.

DESCRIPTION

The xvfb-run command simplifies running X Window System applications that require a display but do not need to be visible. It wraps the application execution within an Xvfb (X Virtual FrameBuffer) server instance. This is particularly useful for automated testing, headless servers, or situations where a graphical display is unavailable. xvfb-run automatically sets up an Xvfb server, executes the specified command within that server's environment (setting the DISPLAY environment variable), and then shuts down the Xvfb server when the command completes. This ensures a clean and isolated environment for the X application to run without interfering with the system's primary display or requiring a physical monitor. The command efficiently manages the lifecycle of the virtual display, making it easy to integrate X applications into non-graphical workflows.
It provides a convenient way to execute GUI programs in a non-GUI environment.
Xvfb must be installed separately.

CAVEATS

xvfb-run relies on the correct configuration of Xvfb. It may not work as expected if Xvfb is not properly installed or configured.
Also, make sure that the user running the command has the necessary permissions to access the Xvfb server. Ensure the command exits correctly to avoid xvfb-run hanging or leaving the Xvfb server running.

USAGE EXAMPLES

xvfb-run --auto-servernum firefox
Runs firefox in a virtual framebuffer using an automatically assigned server number.
xvfb-run --server-args='-screen 0 1024x768x24' ./my_gui_app
Runs ./my_gui_app with a specified screen resolution and color depth.

HISTORY

xvfb-run was created to simplify the process of running X applications in environments without a physical display. It's designed to automate the setup and teardown of Xvfb servers, reducing the complexity of headless GUI testing and other similar tasks. The command has evolved alongside Xvfb itself to improve its reliability and flexibility.

SEE ALSO

Xvfb(1), xauth(1)

Copied to clipboard