The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > SUN Solaris
Google UNIX.COM


SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems .

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Command to release a port in AIX hemanshupatira AIX 5 05-06-2008 08:13 AM
required command to know the port no. Amit_kolurwar SUN Solaris 1 04-23-2008 12:05 AM
disabled telnet now need port 23 or port 22 panzerkw SUN Solaris 3 03-05-2007 11:08 AM
How to set baude rate of Serial port using setserial or other command zaheer031 UNIX for Advanced & Expert Users 1 09-29-2004 08:20 AM
BitTorrent port 6969 blocked... how to get around the blocked port PenguinDevil IP Networking 1 05-05-2004 08:03 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-03-2007
Registered User
 

Join Date: May 2007
Posts: 56
Command to know port no

Hi,

I want to know command which will display which application is running on which port.... apart from netstat,
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-03-2007
Awadhesh's Avatar
Registered User
 

Join Date: Jul 2005
Location: Delhi, India
Posts: 92
configuration file is /etc/inet/services

for ex:
to know about telnet port u can use
# grep telnet /etc/inet/services
telnet 23/tcp.

Awadhesh
Reply With Quote
  #3 (permalink)  
Old 08-03-2007
Registered User
 

Join Date: May 2007
Posts: 56
Thanks Awadhesh for your quick response, but any command is there which will display application name along with port number?
Reply With Quote
  #4 (permalink)  
Old 08-03-2007
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Download lsof from Freeware for Solaris

Then run lsof -i - see man lsof for more.

Cheers,
ZB
Reply With Quote
  #5 (permalink)  
Old 08-03-2007
Awadhesh's Avatar
Registered User
 

Join Date: Jul 2005
Location: Delhi, India
Posts: 92
I am not aware other that netstat.
Reply With Quote
  #6 (permalink)  
Old 08-03-2007
Registered User
 

Join Date: Aug 2007
Posts: 4
Thumbs up Re: Command to know port no.

Hi,

netstat in Solaris will not show which process is using certain port, do fix that try to use pfiles, this is a cool tool in Solaris which shows you all the files openned by the process, since a connection is a file in Unix , using pfiles is easy. Look the following shell script :

-----
for a in `ps -ef | nawk '{print $2}'`
do
pfiles $a | grep 80 (your port number)
done
-----

Later you can automate an improve this script, this is just to give U a clue how to find your stuff there, hope that helps.

Regarding,

Fernando Ramos.
Reply With Quote
  #7 (permalink)  
Old 08-03-2007
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
I actually wrote a fairly comprehensive script to do this a while back

Code:
#!/bin/bash

# use this where lsof (for lsof -i tcp:<port>) isn't available

AWK="/usr/bin/awk"
ECHO="/bin/echo"
PARGS="/usr/bin/pargs"
PFILES="/usr/bin/pfiles"
PS="/usr/bin/ps"
SED="/usr/bin/sed"

${PS} -ef | ${SED} '1d' | while read PS_LINE; do
   PS_PID=$( ${ECHO} "${PS_LINE}" | ${AWK} '{print $2}' )
   PS_PROC=$( ${PARGS} ${PS_PID} | ${SED} -n '1p' | ${SED} 's/^[0-9][0-9]*:[    ]*\(.*\)$/\1/' )
   PORT_USAGE=$( ${PFILES} ${PS_PID} | ${AWK} '/AF_INET/ { printf( "\t%s(%s)\n", $3, $5 ) }' )
   if [ "${PORT_USAGE}" != "" ]; then
      ${ECHO} "${PS_PROC} [PID: ${PS_PID}]"
      ${ECHO} "${PORT_USAGE}"
   fi
done

exit 0
Sample output...
Code:
...
        /usr/lib/inet/xntpd [PID: 366]
        0.0.0.0(123)
        127.0.0.1(123)
        192.168.xx.14(123)
        192.168.xx.15(123)
...
Cheers,
ZB
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:16 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