The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Special Forums > IP Networking
Google UNIX.COM


IP Networking Questions involving TCP/IP, Routers, Hubs, Network protocols, etc go here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Get CDE/dtlogin to stop listening on port 6000 AIXNewbie AIX 0 03-20-2008 12:25 PM
VNC Server http listening port kxchen_home Linux 6 02-06-2004 08:23 PM
Listening on port for incoming data? frustrated1 Shell Programming and Scripting 6 01-16-2004 02:48 PM
port not listening.. Prafulla IP Networking 1 12-12-2001 05:46 AM
Perl Script Listening On A TCP Port emcb Shell Programming and Scripting 1 12-04-2001 09:19 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-09-2007
Registered User
 

Join Date: Jan 2007
Posts: 11
Stumble this Post!
how to find port numbers a web server is listening to

I want to write a program to list all port numbers a process like web server is listening to.Is there a any unix command to find the port numbers and the processes(pid) connected to that port.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-09-2007
Registered User
 

Join Date: Dec 2006
Posts: 55
Stumble this Post!
Quote:
Originally Posted by laddu
I want to write a program to list all port numbers a process like web server is listening to.Is there a any unix command to find the port numbers and the processes(pid) connected to that port.

u can write the script in shell for a particular task of listing

in linux we have commands
lsof -i TCP (displays online open tcp ports)
lsof -i UDP
above commands work for linux only

netstat -anp | head -20

nmap -anp ( if the nmap utility is installed in linux system)


thru netstat only we can get much of the information regarding the open ports
Reply With Quote
  #3 (permalink)  
Old 01-09-2007
sysgate's Avatar
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,160
Stumble this Post!
you can also use "sockstat" if applicable.
Reply With Quote
  #4 (permalink)  
Old 01-10-2007
Registered User
 

Join Date: Dec 2006
Posts: 55
Stumble this Post!
Quote:
Originally Posted by maheshwin
u can write the script in shell for a particular task of listing

in linux we have commands
lsof -i TCP (displays online open tcp ports)
lsof -i UDP
above commands work for linux only

netstat -anp | head -20

nmap -anp ( if the nmap utility is installed in linux system)


thru netstat only we can get much of the information regarding the open ports

sockstat works on BSD
netstat can be used for unix platform of solaris,hpux
Reply With Quote
  #5 (permalink)  
Old 01-10-2007
Registered User
 

Join Date: Dec 2006
Location: CA,United States
Posts: 172
Stumble this Post!
netstat -na |grep LISTEN to find the listening ports in HP-UX,Solaris

netstat -na|grep CONNECTED to find the ports connected in Linux box.
Reply With Quote
  #6 (permalink)  
Old 01-22-2007
Registered User
 

Join Date: Jan 2007
Posts: 366
Stumble this Post!
On solaris:

pfiles <pid>
Reply With Quote
  #7 (permalink)  
Old 02-16-2007
infierno's Avatar
Registered User
 

Join Date: Jul 2005
Location: Asuncion, Paraguay
Posts: 79
Stumble this Post!
You can try, on linux,
Code:
 # netstat -lpn | grep httpd
.. if you know that the server is httpd (apache), there you can figure out what ports and address has apache bound to as well as process' pid.

on freebsd systems try
Code:
# sockstat -ln | grep httpd
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0