list active VNC connections from terminal
9,091
Solution 1
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
Solution 2
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.
Related videos on Youtube
Author by
nick2k3
Updated on September 18, 2022Comments
-
nick2k3 over 1 year
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?