Languages
[Edit]
EN

Bash - list used unix socket files under Linux / Unix

5 points
Created by:
Wade
562

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:

  • -a causes showing both listening and non-listening sockets,
  • -p causes adding process PID and name to results,
  • --unix causes 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 netstat was marked as depricated and may be not available by default (to install it use: sudo apt-get install net-tools).

 

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join