To start a VNC server on a specific port, you need to specify a display number when running the vncserver
command.
Understanding VNC Ports and Display Numbers
When you start a VNC server, it typically uses a display number (e.g., :1
, :2
, :3
). The actual port number that the VNC server listens on is determined by adding 5900 to this display number.
According to the reference:
- Once you're logged into your remote machine, you can start the VNC server by running the
vncserver
command. - If you want to specify a port, you can do so by adding
:<display-number>
to the command. - The actual port number will be 5900 plus the `
`.
Therefore, to target a specific port, you calculate the required display number by subtracting 5900 from your desired port.
Starting VNC with a Specific Port
You start the VNC server on a port corresponding to a specific display number using the following command structure:
vncserver :<display-number>
Replace <display-number>
with the desired display number.
Examples
Here are a few examples demonstrating the relationship between the display number and the resulting port:
Desired Display Number | Resulting Port (5900 + Display Number) | Command |
---|---|---|
:1 |
5901 | vncserver :1 |
:2 |
5902 | vncserver :2 |
:10 |
5910 | vncserver :10 |
By running vncserver
with the appropriate display number, you initiate the VNC server process listening on the corresponding port.