20101102 who is holding that damn port open - plembo/onemoretech GitHub Wiki

title: Who is holding that damn port open? link: https://onemoretech.wordpress.com/2010/11/02/who-is-holding-that-damn-port-open/ author: lembobro description: post_id: 115 created: 2010/11/02 15:44:50 created_gmt: 2010/11/02 15:44:50 comment_status: open post_name: who-is-holding-that-damn-port-open status: publish post_type: post

Who is holding that damn port open?

It's all about using the right tool for the job. I use lsof.

Once you've confirmed the port is actually open (netstat -an | grep -i listen), finding what process is holding a port open is easy.

lsof -i :6003

The response will list out the IDs and user names of everything listening on that port.

[root@example ~]# lsof -i :6003
COMMAND   PID   USER   FD   TYPE    DEVICE SIZE NODE NAME
opmn    24262 oracle   10u  IPv4 209353006       TCP *:6003 (LISTEN)

You can get pretty much the same result by running netstat as root with the "-p" switch:

[root@example ~]# lsof -i :3306
COMMAND  PID  USER   FD   TYPE DEVICE SIZE NODE NAME
mysqld  2493 mysql   10u  IPv4   7506       TCP *:mysql (LISTEN)
[root@usmlrs425 ~]# netstat -anp | grep 3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      2493/mysqld

Copyright 2004-2019 Phil Lembo