How to use the command x11vnc (with examples)
- Linux
- December 25, 2023
The x11vnc
command is a VNC server that enables VNC (Virtual Network Computing) on an existing display server. It allows remote access and control to the server’s graphical user interface. By default, the server will automatically terminate once all clients disconnect from it.
Use case 1: Launch a VNC server that allows multiple clients to connect
Code:
x11vnc -shared
Motivation: This example is useful when you want to allow multiple clients to connect to the VNC server simultaneously. By using the -shared
option, the server allows the share of the connection between multiple clients.
Explanation:
x11vnc
: The command to launch the VNC server.-shared
: The argument to enable shared connection, allowing multiple clients to connect to the server.
Example output:
21/11/30 14:32:18 x11vnc version: 0.9.16 lastmod: 2020-04-08
21/11/30 14:32:18 XFBConfig or XGetWindowAttributes failed.
21/11/30 14:32:18 display: :0.0 rfbListenPort: 5900 webhttpd: no
Use case 2: Launch a VNC server in view-only mode, and which won’t terminate once the last client disconnects
Code:
x11vnc -forever -viewonly
Motivation: This example is useful when you want to have a VNC server that can only be viewed but not controlled by the clients. Additionally, the -forever
option ensures that the VNC server does not terminate even after the last client disconnects, allowing for persistent remote access.
Explanation:
-forever
: The argument to prevent the server from terminating after the last client disconnects.-viewonly
: The argument to enable view-only mode, preventing clients from controlling the server.
Example output:
21/11/30 14:38:24 x11vnc version: 0.9.16 lastmod: 2020-04-08
21/11/30 14:38:24 -forever mode: PERSISTENT SERVER
21/11/30 14:38:24 -viewonly mode: TRUE
21/11/30 14:38:24 The VNC desktop is: :0
21/11/30 14:38:24 Listening for VNC connections on TCP port 5900
Use case 3: Launch a VNC server on a specific display and screen (both starting at index zero)
Code:
x11vnc -display :display.screen
Motivation: This example is useful when you want to specify the display and screen you want to launch the VNC server on. By providing the desired display and screen identifiers, you can control which graphical interface to make accessible remotely.
Explanation:
-display :display.screen
: The argument to specify the display and screen to launch the VNC server on. Replacedisplay
with the desired display index andscreen
with the desired screen index (both starting at zero).
Example output:
21/11/30 14:45:52 x11vnc version: 0.9.16 lastmod: 2020-04-08
21/11/30 14:45:52 -display :0.1 is not a valid display name.
Use case 4: Launch a VNC server on the third display’s default screen
Code:
x11vnc -display :2
Motivation: This example is useful when you want to launch the VNC server on a specific display, especially if you have multiple displays connected to your system. By providing the display index, you can choose which display to make accessible remotely.
Explanation:
-display :2
: The argument to specify the third display’s default screen to launch the VNC server on.
Example output:
21/11/30 14:50:36 x11vnc version: 0.9.16 lastmod: 2020-04-08
21/11/30 14:50:36 -display :2 is a valid display name.
Use case 5: Launch a VNC server on the first display’s second screen
Code:
x11vnc -display :0.1
Motivation: This example is useful when you want to launch the VNC server on a specific screen of a particular display. By providing both the display and screen indexes, you can target a specific screen of a specific display for remote access.
Explanation:
-display :0.1
: The argument to specify the first display’s second screen to launch the VNC server on.
Example output:
21/11/30 14:53:42 x11vnc version: 0.9.16 lastmod: 2020-04-08
21/11/30 14:53:42 -display :0.1 is a valid display name.
Conclusion:
The x11vnc
command is a powerful tool for enabling remote access to an existing display server. By using the various options and arguments, you can customize the behavior of the VNC server and specify which display and screen to make accessible remotely. Whether you need to allow multiple clients, enable view-only mode, or target specific displays and screens, x11vnc
provides the flexibility to suit your remote access needs.