• Home
  • LLMs
  • Docker
  • Kubernetes
  • Java
  • Maven
  • About
Install | Xvfb
  1. Installation
  2. Example (1)
  3. Example (2)
  4. Stop Xvfb

  1. Installation
    Run the following command to install xvfb:
    $ sudo apt install xvfb

    Help:
    $ man Xvfb
    NAME
        Xvfb - virtual framebuffer X server for X Version 11
    
    SYNOPSIS
        Xvfb [ option ] ...
    
    OPTIONS
        -screen screennum WxHxD
            This option creates screen "screennum" and sets its width, height, and depth to W, H, and D respectively.
            By default, only screen 0  exists  and  has  the  dimensions 1280x1024x8.
    
        -fbdir framebuffer-directory
            This option specifies the directory in which the memory mapped files containing the framebuffer memory should be created.
            This  option  only  exists  on machines that have the mmap and msync system calls.
  2. Example (1)
    This example will start Xvfb at display 99.
    Xvfb will listen for connections as server number 99.
    The screen 0 will be depth 8 1280x1024.
    Xvfb will use memory mapped files in ~/xvfb.dir/.
    $ mkdir ~/xvfb.dir/
    
    $ Xvfb :99 -screen 0 1280x1024x8 -fbdir ~/xvfb.dir/ &
    
    #Run xclock at display 99
    $ xclock -display :99 &
    
    #Display the image.
    $ xwud -in xvfb.dir/Xvfb_screen0
  3. Example (2)
    This example will start Xvfb at display 98.
    Xvfb will listen for connections as server number 98.
    Use xwd and xwud to capture/display the virtual screen in/from file.
    $ Xvfb :98 &
    
    $ xclock -display :98 &
    
    $ xwd -out xfvbtest.xwd -root -display :98
    
    $ xwud -in xfvbtest.xwd
  4. Stop Xvfb
    If you want to stop Xvfb from listening for connection:
    #kill the process that has an open connection with Xvfb
    $ ps -ef | grep xclock
    mtitek    4068  2394  0 20:58 pts/8    00:00:00 xclock -display :98
    
    $ kill -9 4068
    
    #clean-up the temp files
    $ ls -alrt /tmp/
    -r--r--r--  1 mtitek  mtitek       11 Nov 28 20:58 .X98-lock
    
    $ rm -rf /tmp/.X98-lock
    
    #kill the Xvfb process
    $ ps -ef | grep Xvfb
    mtitek    4057  2394  0 20:58 pts/8    00:00:00 Xvfb :98
    
    $ kill -9 4057
© 2025  mtitek