Linux command
sockstat 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Example
sockstat
Example
sockstat -4 -l -p [port1,port2]
Example
sockstat -cu
Example
sockstat -P [pid|process]
Example
sockstat -U [uid|user]
Example
sockstat -G [gid|group]
Example
sockstat -R [tcp|udp|raw|unix]
说明
sockstat lists open Internet and Unix domain sockets on the system. It displays information about which processes have which sockets open, useful for network troubleshooting and security auditing. Output includes USER, COMMAND, PID, FD (file descriptor), PROTO (protocol), LOCAL ADDRESS, and FOREIGN ADDRESS for Internet sockets. Multiple filters can be combined to narrow results.
参数
- -4
- Show only IPv4 sockets
- -6
- Show only IPv6 sockets
- -u
- Include Unix domain sockets
- -c
- Show only connected sockets
- -l
- Show only listening sockets
- -o
- Apply filters with OR logic instead of AND
- -p _ports_
- Filter by ports (comma-separated or ranges like 80-443)
- -P _pid|process_
- Filter by process ID or process name
- -U _uid|user_
- Filter by user ID or username
- -G _gid|group_
- Filter by group ID or group name
- -R _protocol_
- Filter by protocol (tcp, udp, raw, unix)
- -h
- Display help
FAQ
What is the sockstat command used for?
sockstat lists open Internet and Unix domain sockets on the system. It displays information about which processes have which sockets open, useful for network troubleshooting and security auditing. Output includes USER, COMMAND, PID, FD (file descriptor), PROTO (protocol), LOCAL ADDRESS, and FOREIGN ADDRESS for Internet sockets. Multiple filters can be combined to narrow results.
How do I run a basic sockstat example?
Run `sockstat` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -4 do in sockstat?
Show only IPv4 sockets