Find what process on port number | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Find what process on port number

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-12-2008
mr_andrew mr_andrew is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 24 February 2010, 9:24 AM EST
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old 12-12-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 
Join Date: Sep 2007
Last Activity: 28 August 2014, 10:17 AM EDT
Location: St. Gallen, Switzerland
Posts: 6,227
Thanks: 121
Thanked 451 Times in 411 Posts

Code:
lsof -p <pidofyourprocess> | grep -E "TCP|UDP"

It should show something like (I took apache2 in my example):

Code:
apache2 30941 root    4u  IPv6 264107             TCP *:www (LISTEN)
apache2 30941 root    6u  IPv6 264112             TCP *:webcache (LISTEN)

You can check this service names (www and webcache) in your /etc/services to get the port number.
Sponsored Links
    #3  
Old 12-12-2008
mr_andrew mr_andrew is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 24 February 2010, 9:24 AM EST
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks.

But if I donīt know the process? I want to find out the process which is using the port. I.e I would like to know which process uses port 80?
    #4  
Old 12-12-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 
Join Date: Sep 2007
Last Activity: 28 August 2014, 10:17 AM EDT
Location: St. Gallen, Switzerland
Posts: 6,227
Thanks: 121
Thanked 451 Times in 411 Posts
Reading the man page for lsof is a good idea.

Another example:

Code:
lsof -i :80
COMMAND   PID     USER   FD   TYPE DEVICE SIZE NODE NAME
apache2 11508 www-data    4u  IPv6 264107       TCP *:www (LISTEN)
apache2 11509 www-data    4u  IPv6 264107       TCP *:www (LISTEN)
apache2 11510 www-data    4u  IPv6 264107       TCP *:www (LISTEN)
apache2 11511 www-data    4u  IPv6 264107       TCP *:www (LISTEN)
apache2 11512 www-data    4u  IPv6 264107       TCP *:www (LISTEN)
apache2 11513 www-data    4u  IPv6 264107       TCP *:www (LISTEN)
apache2 11545 www-data    4u  IPv6 264107       TCP *:www (LISTEN)
apache2 30941     root    4u  IPv6 264107       TCP *:www (LISTEN)
apache2 30952 www-data    4u  IPv6 264107       TCP *:www (LISTEN)
apache2 30953 www-data    4u  IPv6 264107       TCP *:www (LISTEN)
apache2 30955 www-data    4u  IPv6 264107       TCP *:www (LISTEN)

There you get a lot of PIDs involved on port 80 for example.
Sponsored Links
    #5  
Old 12-12-2008
mr_andrew mr_andrew is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 24 February 2010, 9:24 AM EST
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks a lot
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to find what process is using a port in AIX 5L and above. troym72 AIX 2 05-21-2010 10:25 AM
Find port number being used by a given process id sunpraveen Shell Programming and Scripting 3 02-25-2009 11:35 AM
find out unix port number venhart UNIX for Advanced & Expert Users 4 09-20-2008 07:56 AM
How to find the port number of the oracle process thana UNIX for Dummies Questions & Answers 2 03-21-2008 08:14 PM
To find pid from port number gmat HP-UX 6 12-31-2007 06:43 AM



All times are GMT -4. The time now is 05:07 PM.