Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Under Linux I can use netstat -tulpnw and ps, like so:

# netstat -tulpnw | grep :53
tcp        0      0 127.0.0.1:53                0.0.0.0:*                   LISTEN      1482/named          
udp        0      0 127.0.0.1:53                0.0.0.0:*                               1482/named          

# ps aux | fgrep 1482
named     1482  0.0  1.0  93656 44900 ?        Ssl  Sep06   3:17 /usr/sbin/named -u named
root     20221  0.0  0.0   4144   552 pts/0    R+   21:09   0:00 fgrep --color=auto 1482
# 

How can I get the full path of a program bound to a port when using ksh in AIX 6?

share|improve this question
add comment

5 Answers

As recommended by IBM: use lsof -i -n and look for port XY. If you want parseable output from lsof, use the -F flag and parse the output with awk.

You can get pre-compiled binaries for AIX V5. I don't know if there are pre-compiled binaries for V6; if there aren't, get the source and compile it.

share|improve this answer
    
lsof is not always available on AIX:P –  LanceBaynes Sep 25 '11 at 14:30
2  
So Download it or compile it from source, it's recommended by IBM. –  Gilles Sep 25 '11 at 21:53
    
there aren't always "lsof" on the machines... but i could take this as a good answer (other ones are "good" too! ty) –  LanceBaynes Sep 30 '11 at 16:29
add comment

Try using netstat with rmsock.

port=$1
addr=`netstat -Aan | grep $port | awk '{print $1}`
pid=`rmsock $addr tcpcb | awk '{print $9}'`
ps -ef | grep $pid

For netstat, the -A shows the address of any protocol control blocks associated with the sockets, the -a option shows the state of all sockets including those of server processes, and the -n option gives output in numeric form, so you're not wasting time trying to resolve addresses.

rmsock, using the address given in the column1 output of netstat, and using the tcpcb database, will return information about the process holding that socket, including the pid and name.

You can then use ps -ef | grep $pid to get the process information.

You can see this article at IBM Systems Magazine for more info on this.

share|improve this answer
    
this is not event executing correctly on my AIX –  Kiwy Jan 13 at 15:40
add comment

One of the quickest way to find the application locking port is to use lsof or lsof64:

lsof64 -nP | grep $PortNumber

or

lsof -nP | grep $PortNumber

Above will return process ID locking/using given port number. Once you have it then run below to find running application/process

proctree $pid
share|improve this answer
add comment

I'm not familiar with AIX, but have you tried the w or e formatting arguments to ps?

ps uwx | grep 1482
# or 
ps uex | grep 1482
share|improve this answer
    
You can check the manual online. AIX ps does support traditional BSD flags, but how do the flags you indicated help? –  Gilles Sep 25 '11 at 21:51
    
Hm, looks like they do different things on AIX. Although the documentation you referenced includes an l option which prints "USER, PID, %CPU, %MEM, SZ, RSS, TTY, STAT, STIME, TIME, and COMMAND fields" –  frogstarr78 Sep 25 '11 at 21:58
add comment
netstat -ape | grep $PortNumber
share|improve this answer
    
Could you explain what the command is doing? Pasting code without justification isn't very helpful. –  MaxMackie Mar 1 '13 at 21:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.