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

# netstat -tulpnw | grep :53
tcp        0      0      *                   LISTEN      1482/named          
udp        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?


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.

| improve this answer | |

Try using netstat with rmsock.

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.

| improve this answer | |
  • this is not event executing correctly on my AIX – Kiwy Jan 13 '14 at 15:40

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

lsof64 -nP | grep $PortNumber


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
| improve this answer | |

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
| 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 'SO- stop being evil' 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
netstat -ape | grep $PortNumber
| improve this answer | |
  • Could you explain what the command is doing? Pasting code without justification isn't very helpful. – n0pe Mar 1 '13 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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