Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I know which process used the specific TCP port

Status
Not open for further replies.

RedFox4AIX

IS-IT--Management
Dec 22, 2004
24
CA
Hi All,

I have a client complaining a tcp port 10000 was used by another process:

root@gpscam01 # netstat -na|grep 10000
*.10000 Idle
*.10000 *.* 0 0 49152 0 LISTEN
root@gpscam01 #

My question is how can I find out which process is using it?


Also it remind me another question, I always want to know which process is using a specific share memory, let's take an example bellow, how can I find out the process using share memory id=5 key= 0x419c0bc0 ?

root@gpscam01 # ipcs -m
IPC status from <running system> as of Tue Mar 28 08:18:37 EST 2006
T ID KEY MODE OWNER GROUP
Shared Memory:
m 1024 0x410678bc --rw-rw-rw- root root
m 1 0xc6629c9 --rw-r----- root root
m 2 0x6347849 --rw-rw-rw- root root
m 3 0x31000008 --rw-rw-rw- root root
m 1028 0x41067dfe --rw-rw-rw- root root
m 5 0x419c0bc0 --rw-rw-rw- applmgr oaa
m 6150 0x19c09a5 --rw-rw---- mqm mqm
m 1031 0x19c09ad --rw-rw---- mqm mqm


I will appreciate any help from you.

Thanks!
fox
 
Hi All,

I just got it by lsof for tcp port and still need answer for share memory :

root@gpscam01 # lsof |grep 10000
opcctla 13925 root 5u IPv4 0x30130c473f0 0t0 TCP *:10000 (LISTEN)
opcctla 13925 root 7u IPv4 0x30121bc4de8 0t0 UDP *:10000 (Idle)
root@gpscam01 #

also is there any more popular command than lsof?

thanks,
Fox
 
fuser will give you the port a process is using?

I use this if I don't have lsof:
Code:
#!/bin/ksh

line='---------------------------------------------
pids=$(/usr/bin/ps -ef | sed 1d | awk '{print $2}')

if [ $# -eq 0 ]; then
   read ans?"Enter port you would like to know pid for: "
else
   ans=$1
fi

for f in $pids
do
   /usr/proc/bin/pfiles $f 2>/dev/null | /usr/xpg4/bin/grep -q "port: $ans
   if [ $? -eq 0 ]; then
      echo $line
      echo "Port: $ans is being used by PID:\c"
      /usr/bin/ps -ef -o pid -o args | egrep -v "grep|pfiles" | grep $f
   fi
done
exit 0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top