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 01:25 PM
VNC Server http listening port kxchen_home Linux 6 02-06-2004 09:23 PM
Listening on port for incoming data? frustrated1 Shell Programming and Scripting 6 01-16-2004 03:48 PM
port not listening.. Prafulla IP Networking 1 12-12-2001 06:46 AM
Perl Script Listening On A TCP Port emcb Shell Programming and Scripting 1 12-04-2001 10:19 PM

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

Join Date: Jan 2007
Posts: 11
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  
Old 01-09-2007
Registered User
 

Join Date: Dec 2006
Posts: 55
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  
Old 01-10-2007
sysgate's Avatar
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,197
you can also use "sockstat" if applicable.
Reply With Quote
  #4  
Old 01-10-2007
Registered User
 

Join Date: Dec 2006
Posts: 55
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  
Old 01-10-2007
Registered User
 

Join Date: Dec 2006
Location: CA,United States
Posts: 174
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  
Old 01-22-2007
Registered User
 

Join Date: Jan 2007
Posts: 366
On solaris:

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

Join Date: Jul 2005
Location: Asuncion, Paraguay
Posts: 79
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 03:21 AM.


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

Content Relevant URLs by vBSEO 3.2.0