LinuxCommandLibrary

sockstat

List open Internet and Unix domain sockets

TLDR

Show all sockets (IPv4 and IPv6, listening and connected)

$ sockstat
copy
Show IPv4 listening sockets on specific ports
$ sockstat -4 -l -p [port1,port2]
copy
Show connected and Unix sockets
$ sockstat -cu
copy
Filter by process ID or name
$ sockstat -P [pid|process]
copy
Filter by user
$ sockstat -U [uid|user]
copy
Filter by group
$ sockstat -G [gid|group]
copy
Filter by protocol
$ sockstat -R [tcp|udp|raw|unix]
copy

SYNOPSIS

sockstat [-46clouh] [-p ports] [-P pid|process] [-U uid|user] [-G gid|group] [-R protocol]

DESCRIPTION

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.

PARAMETERS

-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

CAVEATS

Requires appropriate permissions to see all sockets; root can see everything. On Linux, similar functionality is provided by ss or netstat. The sockstat command originated on BSD systems and may not be available on all Linux distributions.

HISTORY

sockstat originated on FreeBSD and other BSD systems as a user-friendly alternative to parsing /proc or using netstat. Linux versions provide similar functionality. The tool has been part of BSD since the late 1990s and was ported to Linux as part of various utility packages.

SEE ALSO

ss(8), netstat(8), lsof(8), fuser(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community