How to use the command 'vncviewer' (with examples)
- Linux
- December 25, 2023
The vncviewer
command is used to launch a VNC (Virtual Network Computing) client. This allows users to connect to and interact with a remote computer’s desktop environment over a network connection. The vncviewer
command provides various options to customize the behavior of the VNC client.
Use case 1: Launch a VNC client which connects to a host on a given display
Code:
vncviewer host:display_number
Motivation: This use case is helpful when you want to connect to a specific host and view its desktop on a particular display. For example, if you want to access a remote computer’s desktop on display 1, you can use this command to establish a VNC connection.
Explanation:
host:display_number
: Specifies the host and display number to connect to. Thehost
can be an IP address or hostname of the remote computer, anddisplay_number
represents the specific display on the host’s desktop.
Example output: The VNC client will launch and establish a connection to the specified host on the given display. You will be able to view and interact with the remote computer’s desktop.
Use case 2: Launch in full-screen mode
Code:
vncviewer -FullScreen host:display_number
Motivation: Running the VNC client in full-screen mode allows you to maximize the viewing area and immerse yourself in the remote desktop experience. This can be especially useful when working with applications or environments that require larger screen real estate.
Explanation:
-FullScreen
: This option tells the VNC client to launch in full-screen mode.
Example output: The VNC client will launch in full-screen mode, occupying the entire screen of your local computer. The remote computer’s desktop will be displayed in full size, providing a more immersive experience.
Use case 3: Launch a VNC client with a specific screen geometry
Code:
vncviewer --geometry widthxheight host:display_number
Motivation: In some cases, you may want to customize the screen size of the VNC client window. This can be useful for aligning the remote desktop with your local workspace or if you have specific resolution requirements.
Explanation:
--geometry widthxheight
: This option specifies the desired width and height dimensions of the VNC client window in pixels.
Example output: The VNC client will launch with a window size matching the specified width and height. The remote computer’s desktop will be scaled to fit within the dimensions defined by the geometry arguments.
Use case 4: Launch a VNC client which connects to a host on a given port
Code:
vncviewer host::port
Motivation: If the VNC server on the remote host is running on a non-standard port, you can use this command to connect to the correct port and establish a VNC session.
Explanation:
host::port
: Specifies the host and port number to connect to. Thehost
can be an IP address or hostname of the remote computer, andport
represents the specific port on the host where the VNC server is listening.
Example output: The VNC client will connect to the specified remote host’s VNC server on the given port. You will be able to view and interact with the remote computer’s desktop as usual.