EN
Bash - list used unix socket files under Linux / Unix
5 points
In this short article, we would like to show you, how to show both listening and non-listening unix sockets with corresponing files and processes using Bash.
Quick solution (run the following command):
xxxxxxxxxx
1
netstat -a -p --unix
Where:
-a
causes showing both listening and non-listening sockets,-p
causes adding processPID
and name to results,--unix
causes showing only unix sockets.
Example output:
xxxxxxxxxx
1
Active UNIX domain sockets (servers and established)
2
Proto RefCnt Flags Type State I-Node PID/Program name Path
3
unix 2 [ ACC ] STREAM LISTENING 18181 598/NetworkManager /run/NetworkManager/private-dhcp
4
unix 2 [ ACC ] STREAM LISTENING 18272 942/gnome-session-b /tmp/.ICE-unix/942
5
unix 2 [ ACC ] STREAM LISTENING 23866 1157/Xwayland /tmp/.X11-unix/X1024
6
unix 3 [ ] DGRAM 9765 1/init /run/systemd/notify
7
unix 2 [ ACC ] STREAM LISTENING 9769 1/init /run/systemd/private
8
9
...
10
11
unix 2 [ ] DGRAM 1294 344/systemd-journal
12
unix 2 [ ] DGRAM 21102 911/systemd
13
unix 3 [ ] STREAM CONNECTED 1622 1/init /run/systemd/journal/stdout
14
unix 3 [ ] STREAM CONNECTED 26281 1343/systemd
15
unix 3 [ ] STREAM CONNECTED 21414 942/gnome-session-b @/tmp/.ICE-unix/942
Warning: in Debian 11
netstat
was marked as depricated and may be not available by default (to install it use:sudo apt-get install net-tools
).