
Let us now look into the combination of options that will list ports used by open TCP connections: $ lsof -i -P -sTCP:LISTENĬOMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME Lsof command supports various options to filter the output as per our need. Hence, it has the capability to trace the network connection based on process, user, application, or port. lsof command reads the data from kernel’s proc file system. lsof (List of Open Files) is a utility that lists all the open files in Linux. Using netstat CommandĮverything is a file in Linux. We can find all the available options using the help command ss -help and plug and play with them to get the desired output. Ss is a very powerful command with a wide range of options.

This denotes that the particular socket is in a listening state. Since we have used the flag l in the command, so the “State” (first column) for each row will be LISTEN. This column includes process details like process name, process id, and file descriptors. Moreover, we can find the process associated with that particular port in the sixth column. It is a combination of the IP address and port.


In the command output generated above, the fourth column denotes the local socket address.
