Command:
lsof - list open files ( Very efficient tool useful in troubleshooting )
Catergory:
System Information
Common Usage:
$ lsof -i (Show all connections)
Examples:
Show all connections with -i
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Show only TCP connections
1 2 3 4 5 6 7 | |
-i :port show all networking related to a given port
1 2 3 | |
To show connections to a specific host, use @host
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
To Show what a given user has open using -u
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
See what files and network connections a command is using with -c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
Pointing to a file shows what’s interacting with that file
1 2 3 | |
The -p switch lets you see what a given process ID has open, which is good for learning more about unknown processes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
The -t option returns just a PID
1 2 3 4 | |
Using-a allows you to combine search terms, so the query below says, “show me everything running as king connected to ip xx.xx.xx.xx”
1 2 3 | |