我发现在lsof命令的输出中使用了Unix套接字:
COMMAND PID TID TASKCMD USER FD TYPE DEVICE SIZE/OFF NODE NAME
screen 110970 username 4u unix 0xffff91fe3134c400 0t0 19075659 socket"DEVICE“列包含看起来像内存地址的内容。根据lsof手册页:
DEVICE contains the device numbers, separated by commas, for a character special, block special, regular, directory or NFS file;
or ``memory'' for a memory file system node under Tru64 UNIX;
or the address of the private data area of a Solaris socket stream;
or a kernel reference address that identifies the file (The kernel reference address may be used for FIFO's, for example.);
or the base address or device name of a Linux AX.25 socket device.
Usually only the lower thirty two bits of Tru64 UNIX kernel addresses are displayed.我的问题是,我用0xffff91fe3134c400值来查看这些值中的哪些?
此外,我如何与它互动呢?我知道我可以使用netcat连接到Unix域套接字,但是从在线阅读示例可以看出,您需要指定一个文件。
发布于 2022-01-27 08:32:56
我不知道如何回答第二个问题,但是对于第一个问题,您可以使用+E标志lsof来显示套接字的端点。从手册页:
E +E指定,Linux管道、Linux UNIX套接字和Linux伪终端文件应与端点信息一起显示,并显示端点的文件。
例如,下面是来自某个问题的一个例子,他试图找出top进程的fd 6的端点:
# lsof -d 6 -U -a +E -p $(pgrep top)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
dbus-daem 874 messagebus 12u unix 0xffff9545f6fee400 0t0 366381191 /var/run/dbus/system_bus_socket type=STREAM ->INO=366379599 25127,top,6u
top 25127 root 6u unix 0xffff9545f6fefc00 0t0 366379599 type=STREAM ->INO=366381191 874,dbus-daem,12u-U标志用于lsof只显示Unix文件。
注意,您将只看到侦听进程的套接字文件的名称。另一个进程将不显示unix文件的名称,但是使用+E lsof将显示侦听套接字文件的inode,还将为侦听该套接字的进程添加一行(以及套接字文件名)。
在本例中,请注意,我们只要求lsof显示top命令的文件描述符,但是lsof为dbus-daem添加了另一行--即侦听过程,它侦听的套接字文件是/var/run/dbus/system_bus_socket。
type=STREAM ->INO=366381191 874,dbus-daem,12u)交互。/var/run/dbus/system_bus_socket type=STREAM ->INO=366379599 25127,top,6u)的侦听端,在那里您可以看到套接字文件名是/var/run/dbus/system_bus_socket。https://unix.stackexchange.com/questions/688082
复制相似问题