Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I find out what program's on the other end of a local socket?

Tags:

A process on my Linux system, strace tells me, is talking on a socket which has file descriptor 10. lsof tells me that this is a unix socket with inode 11085, and netstat further tells me that inode 11085 a stream socket, and that it's connected.

Given that this process doesn't have any other threads, there must therefore be another process on the system that's connected to the other end of this socket. How do I find out what it is?

Update:

There's some illumination from the lsof author here. Essentially, it seems that Linux just doesn't provide this information.

like image 380
daf Avatar asked May 04 '09 16:05

daf


People also ask

What is inode in netstat?

The inode shown by netstat is the inode of your socket in sockfs (a virtual filesystem holding inodes for sockets in the system).

Are sockets FIFO?

For named pipes (FIFO), two processes shares one file - one process writes to the FIFO, and the other reads from it. For a socket, the processes got one "file" ("Everything is a file") each, and a connection is established between them - which of course really happens through network ports.


2 Answers

ss -p

will tell. (Provided the socket is not owned by the kernel itself.)

like image 163
user562374 Avatar answered Sep 22 '22 04:09

user562374


Does netstat -p help ?

From Manpage:

  -p,
  --program Show the PID and name of the program to which each socket belongs.
like image 22
HaBaLeS Avatar answered Sep 24 '22 04:09

HaBaLeS