Command to know port no


 
Thread Tools Search this Thread
Operating Systems Solaris Command to know port no
# 1  
Old 08-03-2007
Command to know port no

Hi,

I want to know command which will display which application is running on which port.... apart from netstat,
# 2  
Old 08-03-2007
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
# 3  
Old 08-03-2007
Thanks Awadhesh for your quick response, but any command is there which will display application name along with port number?
# 4  
Old 08-03-2007
Download lsof from Freeware for Solaris

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

Cheers,
ZB
# 5  
Old 08-03-2007
I am not aware other that netstat.
# 6  
Old 08-03-2007
MySQL 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.
# 7  
Old 08-03-2007
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to find port number wwn of particular port on dual port HBA,?

please find the below o/p for your reference bash-3.00# fcinfo hba-port HBA Port WWN: 21000024ff295a34 OS Device Name: /dev/cfg/c2 Manufacturer: QLogic Corp. Model: 375-3356-02 Firmware Version: 05.03.02 FCode/BIOS Version: BIOS: 2.02; fcode: 2.01;... (3 Replies)
Discussion started by: sb200
3 Replies

2. Shell Programming and Scripting

Need a command to change the port region

portsuf=25 port=20925 I need to replace 09 with 25 It should be like 22525. Can some please help with command or script. (4 Replies)
Discussion started by: bhas85
4 Replies

3. Shell Programming and Scripting

command to match ethernet port to network card

hi I juts want to know if there is a command that checks if an ethernet port corresponds to a network card. ex. I have 3 network cards, one is two ports, and the other two 8 ports. How do I know that eth0 corresponds to the the two-port network card and eth9 corresponds to the first 8-port... (2 Replies)
Discussion started by: h0ujun
2 Replies

4. UNIX for Dummies Questions & Answers

Need Unix command to get all processes running on a port

Hi, Can someone provide me the Linux command to get the list of all processes running on a particular port. Thanks, Sandy (1 Reply)
Discussion started by: sandy8765
1 Replies

5. Shell Programming and Scripting

Monitor Port, if active, pipe command to screen

I am a linux newbie and I am learning. I need a script that will monitor a port and if active -- only active, not listening or waiting -- then pipe some commands to the screen as if they were typed on the keyboard. Can a bash or perl script do this and if so, could someone help me out? Thanks. (0 Replies)
Discussion started by: bulgin
0 Replies

6. Shell Programming and Scripting

command to know the application running of the port

Hi, is there any command to findout that which application is using the particular port. or whether any port is occupied with the specfic process id ? (4 Replies)
Discussion started by: mail2sant
4 Replies

7. Solaris

Few things related to HBA port & fcinfo command

Hi Gurus I need to know few things related to HBA port & fcinfo command I have a server where there are 4 HBA ports cards are their. Out of 4 ports 2 are in use & 2 are not in use when I check it physicall. Now I want to know the command through which I can get information about all above... (6 Replies)
Discussion started by: girish.batra
6 Replies

8. AIX

command to monitor the Serial port

Hi, Can anyone please tell me how to check the status of the serial port ?? for example,in Sun os we use the command pmadm to see the status of the serial port-- So is there any command or method in AIX,So that i can see the serial port status ?? thanks in advance ... (1 Reply)
Discussion started by: smartgupta
1 Replies

9. AIX

Command to release a port in AIX

Hi All, I wanna know the command to release a particualr port in AIX machine without rebooting it. # netstat -a | grep 7100 tcp4 0 0 loopback.7100 *.* LISTEN # In the above example, how to release the port 7100 Thanks in advance. -Hemanshu (5 Replies)
Discussion started by: hemanshupatira
5 Replies

10. Solaris

required command to know the port no.

Can anybody have the command to know the port no using unix command for the weblogic server application. (1 Reply)
Discussion started by: Amit_kolurwar
1 Replies
Login or Register to Ask a Question