Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for a way to list all the active VNC connection to a machine. I know I can get all the active connection of the machine by running netstat -na but I don't know how to filter just the connection for the VNC server. I am running OSX 10.8.3 , any hint?

share|improve this question
up vote 1 down vote accepted

VNC runs on port 5900 by default, so you should be able to do:

netstat -na | grep '[:.]5900'

(OS X uses . as a port delimiter, but on Linux it's : — the pattern above will match both)

Example on my OS X machine:

% netstat -na | grep '[:.]5900'
tcp4       0      0  *.5900                 *.*                    LISTEN     
tcp6       0      0  *.5900                 *.*                    LISTEN 
share|improve this answer

If you are running xrdp to connect to vnc, then 5900 will not show all the connections. Here is a slightly different answer:

netstat -na | grep '[:.]5900'

gives:

tcp        0      0 127.0.0.1:5918          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:5919          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:5913          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:5914          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:5915          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:5916          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:5917          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:5913          127.0.0.1:54546         ESTABLISHED
tcp        0      0 127.0.0.1:54546         127.0.0.1:5913          ESTABLISHED

Also see this answer for how to dig the port out of the process.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .