lsof command (Linux)

lsof stands for "list open files". So actually it shows all files used by some processes of a system. As in linux many interesting resources are modeled as files, lsof command becomes very useful tool.

Let's get best of it!

In the absence of any options, lsof lists all open files belonging to all active processes of a system.

lsof

Network connections with lsof

The interesting option here is the -i that should be followed by the Internet address which is specified in the following form:

[4|6][protocol][@hostname|hostaddr][:service|port]

4 and 6 stand for ip protocol versions, the rest should be self expanded. Let's get hands on:

#Show all open connections
lsof -i
# Show all open TCP connections
lsof -i TCP