how to get process id attached with particular port in solaris

When you need to know process id attached with particular port use below command.

pfiles /proc/* 2>/dev/null | nawk ' /^[0-9]*:/ { pid=$0 } /port: 7085$/ { printf("%s %s\n",pid,$0);}'

  • pfiles /proc/* is retrieving all processes file descriptors details
  • 2>/dev/null is dropping out errors due to transient processes died in the meantime
  • each line starting with a number followed by a colon reports the process id and details, it is stored in the awk pid variable
  • when a line ends with the string port: <portnumber> (here is 7085), the corresponding pid variable is displayed.
Note: you need the required privilege(s) to get port information from processes you do not own (root has all privileges).

Comments

Popular posts from this blog

Linux File and Directory Permissions

How to Disable SSL for Webmin

INSTALL CISCO VPN CLIENT ON WINDOWS 10 (32 & 64 BIT). FIX REASON 442