Closed lingceng closed 6 years ago
:Preview can not get the right port on my Macbook. And I find out the lsof command gets the port name than the port number.
lsof
~/workspace/smart $ lsof -an -iTCP -sTCP:LISTEN -p23663 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ruby 23663 lingceng 33u IPv4 0xce7caf9daa1e02f5 0t0 TCP *:exlm-agent (LISTEN)
I add a -P option to fix it. This option inhibits the conversion of port numbers to port names for network files.
-P
~/workspace/smart $ lsof -anP -iTCP -sTCP:LISTEN -p23663 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ruby 23663 lingceng 33u IPv4 0xce7caf9daa1e02f5 0t0 TCP *:3002 (LISTEN)
See: https://explainshell.com/explain?cmd=lsof+-anP+-iTCP+-sTCP%3ALISTEN+-p122 https://debian-administration.org/article/184/How_to_find_out_which_process_is_listening_upon_a_port
Thanks!
:Preview can not get the right port on my Macbook. And I find out the
lsof
command gets the port name than the port number.I add a
-P
option to fix it. This option inhibits the conversion of port numbers to port names for network files.See: https://explainshell.com/explain?cmd=lsof+-anP+-iTCP+-sTCP%3ALISTEN+-p122 https://debian-administration.org/article/184/How_to_find_out_which_process_is_listening_upon_a_port