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):
netstat -a -p --unix
Where:
-acauses showing both listening and non-listening sockets,-pcauses adding processPIDand name to results,--unixcauses showing only unix sockets.
Example output:
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 18181 598/NetworkManager /run/NetworkManager/private-dhcp
unix 2 [ ACC ] STREAM LISTENING 18272 942/gnome-session-b /tmp/.ICE-unix/942
unix 2 [ ACC ] STREAM LISTENING 23866 1157/Xwayland /tmp/.X11-unix/X1024
unix 3 [ ] DGRAM 9765 1/init /run/systemd/notify
unix 2 [ ACC ] STREAM LISTENING 9769 1/init /run/systemd/private
...
unix 2 [ ] DGRAM 1294 344/systemd-journal
unix 2 [ ] DGRAM 21102 911/systemd
unix 3 [ ] STREAM CONNECTED 1622 1/init /run/systemd/journal/stdout
unix 3 [ ] STREAM CONNECTED 26281 1343/systemd
unix 3 [ ] STREAM CONNECTED 21414 942/gnome-session-b @/tmp/.ICE-unix/942
Warning: in Debian 11
netstatwas marked as depricated and may be not available by default (to install it use:sudo apt-get install net-tools).