How to find what process is using a port in AIX 5L and above.


 
Thread Tools Search this Thread
Operating Systems AIX How to find what process is using a port in AIX 5L and above.
# 1  
Old 05-19-2010
How to find what process is using a port in AIX 5L and above.

There have been a lot of threads about how to find processes that are using a specific port on an AIX server. After long hours of research and reading countless "you can't do that" responses, I finally found the answer.

YES IT CAN BE DONE! YES ITS EASY. NO, I DON'T KNOW WHY NO ONE GETS THIS ANSWER WHEN THEY ASK.

So here it is:

Recently, we had an issue with a port conflict on our server. Something was LISTENING on port 14248. You can find whether a port is in use by using the netstat command and grepping for the port number in question.
Code:
 
/>netstat -an | grep 14248
tcp        0      0  *.14248                *.*                    LISTEN

However, this is not enough to tell you what process is using the port, only that its being used. You can, however, add the -A argument to the netstat command and then use that output as an argument to the rmsock command to find the PID of the process using the port.
Code:
# netstat -Aan |grep 14248
f10007000864ebb0 tcp        0      0  *.14248            *.*                LISTEN
 
# rmsock f10007000864ebb0 tcpcb
The socket 0x864e808 is being held by proccess 143640 (java).
 
 
# ps -ef |grep 143640
    root  143640  127270   0   May 15      -  3:06 /var/opt/tivoli/ep/_jvm/jre/bin/java

Walla!! We see that the Tivoli java process is using port 14248.

Enjoy your new found power to find what process is using a port on your AIX server!

Cheers,
Troy Morton
Senior Technical Analyst
Hospital Sisters Health Systems

Last edited by troym72; 05-19-2010 at 05:48 PM..
This User Gave Thanks to troym72 For This Post:
# 2  
Old 05-21-2010
Quote:
Originally Posted by troym72
There have been a lot of threads about how to find processes that are using a specific port on an AIX server. After long hours of research and reading countless "you can't do that" responses, I finally found the answer.[...]
It took 5 seconds to google this link from IBM IBM - Who's using my port?
# 3  
Old 05-21-2010
lsof

In the AIX Toolbox for Linux, there is a program called "lsof" which makes finding this information even easier. It can be downloaded from IBM's website here:

IBM AIX Toolbox for Linux Applications - Alphabetical Listing

You can pass it a "-i" followed by a colon and port number and you'll be shown the PID of the process using that port number (use the "grep LISTEN" to get the listening port and not the established connections):

Code:
host:/:$ which lsof
/usr/sbin/lsof
host:/:$ lsof -i :22 | grep LISTEN
sshd     2293958 root    3u  IPv4 0xf100050000489bb0      0t0  TCP *:ssh (LISTEN)
host:/:$ ps -ef | grep 2293958
    root  2293958  2949244   0   May 04      -  0:08 /usr/sbin/sshd
    root  6553842  2293958   0 08:33:52      -  0:00 sshd: user1 [priv]
    root 12910638  4522154   2 09:23:02  pts/1  0:00 grep 2293958
host:/:$

Way easier to remember.

Last edited by kah00na; 05-21-2010 at 11:33 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash script, find the next closed (not in use) port from some port range.

hi, i would like to create a bash script that check which port in my Linux server are closed (not in use) from a specific range, port range (3000-3010). the print output need to be only 1 port, and it will be nice if the output will be saved as a variable or in same file. my code is: ... (2 Replies)
Discussion started by: yossi
2 Replies

2. Solaris

How to find port number wwn of particular port on dual port HBA,?

please find the below o/p for your reference bash-3.00# fcinfo hba-port HBA Port WWN: 21000024ff295a34 OS Device Name: /dev/cfg/c2 Manufacturer: QLogic Corp. Model: 375-3356-02 Firmware Version: 05.03.02 FCode/BIOS Version: BIOS: 2.02; fcode: 2.01;... (3 Replies)
Discussion started by: sb200
3 Replies

3. IP Networking

Tcp ip port open but no such process (merged: Release A Port)

i want to kill a tcp connection by killing its pid with netstat -an i got the tcp ip connection on port 5914 but when i type ps -a or ps-e there is not such process running on port 5914 is it possible that because i do not log on with proper user account i can not see that process running? (30 Replies)
Discussion started by: alinamadchian
30 Replies

4. Shell Programming and Scripting

AIX: Find a process older than 15days

Hi All, My application has specific processes when the developers start using respective GUI . I would like to find related process on server side that is older than 15 days for my application. I am using AIX 6.0. Could you please help with the command on how to find the older process? ... (5 Replies)
Discussion started by: chandu123
5 Replies

5. AIX

Find CPU per process in AIX

Hi. I am looking for a command that will return me the amount of CPU used by a specific process in AIX environment. I know there is TOPAS - but it is interactive and I need to get this information from system that connects remotely via SSH. Using writing to files and than reading them is also... (1 Reply)
Discussion started by: yamsin789
1 Replies

6. Shell Programming and Scripting

Find port number being used by a given process id

Unix gurus, I have a requirement wherein I want to find the port number for a given process id. Is it possible? If so how? TIA, Regards, Praveen (3 Replies)
Discussion started by: sunpraveen
3 Replies

7. UNIX for Dummies Questions & Answers

Find what process on port number

Hi, I am on a Sun Solaris and I want to find out which process is allocated on a certain port. How can I do that? BR Andreas (4 Replies)
Discussion started by: mr_andrew
4 Replies

8. AIX

Cmd to find CPU utiliz of a process in AIX

Hello All, I wanna find the CPU utilization of a specific process running on AIX OS. I have its pid, but not sure about the command. iostat sar 5 5 vmstat All the above give me system CPU utilization. Is there a way to find for a specific pid??? Thanks, Ankita (11 Replies)
Discussion started by: Ankita
11 Replies

9. Solaris

How to find the process that is using the port 80 and apache server.

How to find the process that is using the port 80 and apache server. When i used the command 'netstat -a|grep 80' it given that port 80 is in listening mode. I had used the following command: telnet localhost 80 GET / I had got some HTML script. But when I accessed the GUI ( url is... (7 Replies)
Discussion started by: vamshikrishnab
7 Replies

10. UNIX for Dummies Questions & Answers

How to find the port number of the oracle process

Hi Unix Gurus, Can we find out the port number used by the oracle process is running.I tried to search the forum but coudnt find. Can anyone help me out with the command (2 Replies)
Discussion started by: thana
2 Replies
Login or Register to Ask a Question