【Network】查看正在使用的 Unix Domain Socket

Posted by 西维蜀黍 on 2021-07-16, Last Modified on 2021-09-21

Linux

netstat

$ netstat -a -p --unix

macOS

netstat

$ netstat -a -f unix

lsof

List the processes opening a file via Unix domain socket

$ lsof /tmp/echo.sock
COMMAND     PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
___go_bui 13785 shiwei    3u  unix 0xcc59970df46632e9      0t0      /tmp/echo.sock
___go_bui 13785 shiwei    7u  unix 0xcc59970de99c6161      0t0      /tmp/echo.sock

List all Files used by Unix Domain Socket

$ lsof -U
COMMAND     PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
distnoted   410 shiwei    3u  unix 0xcc59970de99c3ca9      0t0      ->0xcc59970de58b4669
secd        424 shiwei    3u  unix 0xcc59970de99c4091      0t0      ->0xcc59970de58b4669
UserEvent   466 shiwei    3u  unix 0xcc59970de99c5cb1      0t0      ->0xcc59970de99c5d79
UserEvent   466 shiwei    4u  unix 0xcc59970de99c5b21      0t0      ->0xcc59970de58b4669
UserEvent   466 shiwei   17u  unix 0xcc59970de99c3a51      0t0      ->0xcc59970de99c3d71
rapportd    471 shiwei    3u  unix 0xcc59970de99c3731      0t0      ->0xcc59970de58b4669
rapportd    471 shiwei    9u  unix 0xcc59970df4664e41      0t0      ->0xcc59970df4662f01
rapportd    471 shiwei   11u  unix 0xcc59970df4663799      0t0      ->0xcc59970df4664b21
rapportd    471 shiwei   14u  unix 0xcc59970df4663091      0t0      ->0xcc59970df4663159
Sublime     473 shiwei    3u  unix 0xcc59970de99c5351      0t0      /tmp/Sublime Text.4cff18d2bab96a93366319a9e0fa060d.cd247256981dd6a8c8b93b5930202e9d.sock

Reference