Go Back   The UNIX and Linux Forums > Special Forums > IP Networking


IP Networking Learn TCP/IP, Internet Protocol, Routing, Routers, Network protocols in this UNIX and Linux forum.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-09-2007
Registered User
 
Join Date: Jan 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Sponsored Links
    #2  
Old 01-10-2007
Registered User
 
Join Date: Dec 2006
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #3  
Old 01-10-2007
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
 
Join Date: Nov 2006
Location: Bulgaria
Posts: 1,419
Thanks: 0
Thanked 6 Times in 6 Posts
you can also use "sockstat" if applicable.
    #4  
Old 01-10-2007
Registered User
 
Join Date: Dec 2006
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #5  
Old 01-10-2007
Registered User
 
Join Date: Dec 2006
Location: CA,United States
Posts: 199
Thanks: 1
Thanked 0 Times in 0 Posts
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.
Sponsored Links
    #6  
Old 01-22-2007
sb008 sb008 is offline Forum Advisor  
Registered User
 
Join Date: Jan 2007
Posts: 398
Thanks: 1
Thanked 3 Times in 3 Posts
On solaris:

pfiles <pid>
Sponsored Links
    #7  
Old 02-16-2007
infierno's Avatar
Registered User
 
Join Date: Jul 2005
Location: Asuncion, Paraguay
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
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

Sponsored Links
Closed Thread

Tags
linux, linux commands

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 if remote n/w port is listening on HP-UX from the binary einsteinBrain IP Networking 3 01-19-2012 10:52 AM
how to check remote server port listening from application. einsteinBrain HP-UX 0 01-18-2012 01:33 PM
Find file that maps to a listening port phpfreak Shell Programming and Scripting 2 02-27-2010 08:55 PM
VNC Server http listening port kxchen_home Linux 6 02-06-2004 11:23 PM
port not listening.. Prafulla IP Networking 1 12-12-2001 08:46 AM



All times are GMT -4. The time now is 11:38 PM.