How to easily identify socket given a PID on Linux?

Tags
linux

 
Thread Tools Search this Thread
# 8  
Old 04-06-2017
Hi,

The difficult part here would be coming up with a generic solution, since what you need from each netstat output would appear to depend on actual human knowledge of which of the listening ports is the 'correct' one. From a technical perspective, they all are: PID 32538 really is listening on ports 7666 and 38970 on all bound IPs, and on port 13804 on the IP 10.2.228.79 specifically.

So aside from you knowing which of these is the one you want, you'd need some way of identifying something that the ports you're after will actually always have in common, if you want a generic scriptable run-one-command-and-get-the-answer solution. Is there something you would always look for or which would be scriptably identifiable as the signifier of which port was the 'correct' one ? If so, then if you can give a bit more detail we may be able to narrow this down further.

As for the fd command - I've never heard of that one, sorry. Doesn't seem to either be installed or to be an option for installation on any Linux or Solaris system I currently have access to.
# 9  
Old 04-06-2017
Hi.
Quote:
Originally Posted by drysdalk
... As for the fd command - I've never heard of that one, sorry. Doesn't seem to either be installed or to be an option for installation on any Linux or Solaris system I currently have access to.
Perhaps:
Code:
NAME
       fd - file & directory maintenance tool

SYNOPSIS
       fd  [ -abCefhiklmNnPrSsTtuvx ] [ -NAME=value ] [ directory [ directory2
       ...  ]]
       fdsh [ -abCcefhiklmNnPrSsTtuvx ] [ args ]

DESCRIPTION
       Fd is a file & directory maintenance tool considered for the text  ter-
       minals  on general UNIX.  It aims for a clone of the same named utility
       which is made for the PC/AT compatible machine and PC-9800 series.   In
       fact, it is upper compatible functionally.

See Debian package fdclone:
Code:
fd      file & directory maintenance tool (man)
Path    : /usr/bin/fd
Version : - ( /usr/bin/fd, 2014-08-03 )
Type    : ELF 64-bit LSB executable, x86-64, version 1 (SYSV ...)
Help    : probably available with -h

For a system like:
Code:
OS, ker|rel, machine: Linux, 3.16.0-4-amd64, x86_64
Distribution        : Debian 8.7 (jessie)

Best wishes ... cheers, drl

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Socket dual client/server Linux godna Programming 3 11-09-2014 02:02 PM
Need script for killing Pid in Linux roshan9995 UNIX for Dummies Questions & Answers 2 01-21-2014 11:25 AM
Identify CPU usage on the Linux server govindts Shell Programming and Scripting 4 02-13-2012 02:14 PM
Packets sent from Linux TCP socket bix_20002000 IP Networking 1 01-24-2012 05:15 PM
Identify failed disk in Linux RAID Loic Domaigne UNIX for Advanced & Expert Users 2 11-01-2011 05:28 PM
STILL can't buy a Linux PC easily KenJackson What is on Your Mind? 7 12-10-2010 01:32 AM
help me about sending file through socket udp with c in linux tung1984 Programming 1 08-19-2010 12:46 PM
how to identify the raid type on Linux? melanie_pfefer Linux 2 10-31-2008 11:52 AM
Help needed linux socket programming in c esmeco Programming 1 10-28-2008 10:55 AM
socket close() -w- pthreads linux 2.6.18.2-34 (suse) SMP ramen_noodle Programming 1 02-06-2008 10:22 AM
Fedora Linux for Socket Program Development venkatesh.n UNIX for Advanced & Expert Users 0 01-16-2008 04:14 AM
how to find the owner PID of open socket on Solaris9? sleepy_11 UNIX for Dummies Questions & Answers 1 12-11-2007 06:18 AM
How to Write Linux Friendly Async Socket I/O siegfried Programming 3 05-25-2007 08:10 AM
How to identify who rebooted the linux server bache_gowda UNIX for Dummies Questions & Answers 1 05-08-2006 10:16 AM
Session PID & socket connection pid pcx26 UNIX for Dummies Questions & Answers 1 03-30-2006 12:06 PM